search
HomeDevelopment ToolsgitThis article will help you understand what Git version management is

This article brings you relevant knowledge about Git version management. The version management tool can record each modification. As long as it is submitted to the version repository, you can find the status at any previous time. ,I hope everyone has to help.

This article will help you understand what Git version management is

Git is a "distributed version management tool".
The version management tool can record every modification. As long as it is submitted to the version warehouse, the status at any previous time can be found.
We have all used the undo function when writing, but undo can only go back a limited number of steps. Usually, the editing software is closed and then reopened. At this time, the undo record has been cleared. The "version management tool" is different. It can record every modification. As long as it is submitted to the version warehouse, you can find the status at any previous time.

Create warehouse

After installing the git software, create a new folder in any directory, open it, and then execute git init to create a new git warehouse (this command A hidden subdirectory named .git will be created).

Check out the warehouse

Execute the command git clone remote project address to clone the warehouse on the remote server.

Git status

Git has three states, namely committed, modified, and staged.

  • Modified: Modified means that the file has been modified but has not been saved to the database.
  • Staged (staged): Indicates that the current version of a modified file has been marked so that it will be included in the next submitted snapshot.
  • Committed: The data has been safely saved in the local database.

The three states of Git correspond to the three workflows of the local warehouse. This low warehouse is composed of three trees maintained by git.

  • The first one is the working directory, which holds the actual files, additions and deletions of files and content;
  • The second one is the temporary storage area (Index), which is like a cache area and is temporarily saved. change. Enter git add filename, and the changes will be placed in the temporary storage area.
  • The third one is HEAD, pointing to the last submitted result. Enter the git commit command, and the changes will be placed in the local warehouse. What comes after the commit can be called a version.
    This article will help you understand what Git version management is

Basic git workflow:

  • Propose changes (add to staging area)
    Use the command git add (for a specific file) or git add * (for all files) can propose changes (add them to the staging area).
  • Submit changes
    Use the command git commit -m "code submission information" to actually submit the changes. After execution, the changes are submitted to HEAD, but have not yet reached the remote warehouse.
  • Push changes
    Use the command git push origin master to submit the changes to the remote warehouse master branch (usually not submitted directly to the master branch, but pushed to your own branch, and then merge after verification ).

Branch

The master branch was mentioned earlier, so how to understand the branch intuitively?

Branches are used to insulate feature development. When creating a repository, master is the "default" branch. Develop on other branches and merge them into the master branch when finished.
This article will help you understand what Git version management is

git branch test1 Create a branch named test1.
git checkout test1 Switch the current branch to test1
git checkout -b test1 Create a branch called "test1" and switch to it.
git checkout master Switch back to the master branch.
git branch -d test1 Delete the newly created branch.
git push origin Push the branch to the remote warehouse.
git merge test Merge branches.

Update and merge

Use the command git pull "remote branch name" to get the code from the remote and merge it into this lower version (get (fetch) in the working directory and merge ( merge) Remote changes)
Use the command git merge "branch name" to merge other branches into the current branch.

In the first two cases, git will try to automatically merge the changes. However, conflicts may occur during merging, and you need to manually modify the files to merge these conflicts. After making changes, execute git add to mark them as merged successfully. Before merging changes, you can use git diff to observe whether there are differences.

Replace local changes

If you make a mistake, you can use the command git checkout - to replace the local changes. This command will replace the files in the working directory with the latest content in HEAD (changes and new files that have been added to the staging area will not be affected)

Removal and reinstallation of remote warehouses Naming

Rename test to test1: git remote rename test test1
Remove remote warehouse test1: git remote rm test1

Undo operation

Cancel the temporary file: git reset filename
Undo the modification to the file: git checkout –filename

History record

Use git log You can get the history of the local warehouse.
Use the command git log --author=bob to view only the commit records of a certain person. Add some parameters to modify the output to get the results you want.
Check which files have changed: git log --name-status

Recommended study: "Git Tutorial"

The above is the detailed content of This article will help you understand what Git version management is. For more information, please follow other related articles on the PHP Chinese website!

Statement
This article is reproduced at:CSDN. If there is any infringement, please contact admin@php.cn delete
Git vs. GitHub: Exploring Their RolesGit vs. GitHub: Exploring Their RolesApr 16, 2025 am 12:06 AM

Git and GitHub are different tools: Git is a distributed version control system for managing code versions and collaborative development; GitHub is an online platform based on Git, providing code hosting and collaboration tools. Git's main features include version management, branch management, and collaborative development, while GitHub provides code hosting, collaboration tools and social networking capabilities.

GitHub: A Hub for Open Source and Software DevelopmentGitHub: A Hub for Open Source and Software DevelopmentApr 15, 2025 am 12:10 AM

GitHub is a Git-based version control system hosting platform that provides version control, collaborative development and community communication functions. Using GitHub can improve development efficiency and code quality.

Git and GitHub: What's the Relationship?Git and GitHub: What's the Relationship?Apr 14, 2025 am 12:10 AM

Git and GitHub are different tools: Git is software for version control, and GitHub is an online platform based on Git. 1.Git allows you to track file changes and collaborative development. 2. GitHub provides code hosting and collaboration tools to enhance team development efficiency.

GitHub: The Platform for Developers and ProjectsGitHub: The Platform for Developers and ProjectsApr 13, 2025 am 12:01 AM

The core features of GitHub include version control, branch management, code review, issue tracking and project management. 1. Version control and branch management are based on Git, allowing tracking of code changes and experimental development. 2. Code review is implemented through PullRequest to improve code quality and team collaboration. 3. Issues tracking and project management are carried out through Issues and the project management board to improve project transparency and traceability.

GitHub in Action: Examples and Use CasesGitHub in Action: Examples and Use CasesApr 12, 2025 am 12:16 AM

GitHub is a powerful tool to improve the efficiency and quality of software development. 1) Version control: manage code changes through Git. 2) PullRequests: Conduct code review and improve code quality. 3) Issues: Track bugs and project progress. 4) GitHubActions: Automate the construction, testing and deployment process.

Git vs. GitHub: Version Control and Code HostingGit vs. GitHub: Version Control and Code HostingApr 11, 2025 am 11:33 AM

Git is a version control system, and GitHub is a Git-based code hosting platform. Git is used to manage code versions and supports local operations; GitHub provides online collaboration tools such as Issue tracking and PullRequest.

What is Git in simple words?What is Git in simple words?Apr 09, 2025 am 12:12 AM

Git is an open source distributed version control system that helps developers track file changes, work together and manage code versions. Its core functions include: 1) record code modifications, 2) fallback to previous versions, 3) collaborative development, and 4) create and manage branches for parallel development.

Is Git the same as GitHub?Is Git the same as GitHub?Apr 08, 2025 am 12:13 AM

Git and GitHub are not the same thing. Git is a version control system, and GitHub is a Git-based code hosting platform. Git is used to manage code versions, and GitHub provides an online collaboration environment.

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Chat Commands and How to Use Them
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

Atom editor mac version download

Atom editor mac version download

The most popular open source editor