Directory
- Use of git version management tools
- 1. Download and install git
- 1. Download and install git in Windows
- 2. Install git in Linux
- Ii. Common commands
- Iii. Git Repository
- 1. Configure Warehouse Information
- 2. Create and manage a repository
- Iv. Remote Repository
- 5. Branch Management
- Vi. Tag Management
Git version management tool 1. Download and install git 1. Download and install git in Windows
Git git Official Website
After the download, click the default installation.
You can see two EXE programs in the GIT folder.
1.git-bash.exe
2.git-cmd.exe
The first and last two EXE programs are the same. It means that we need to use git commands to operate. Command Line Mode.
There is a git-gui.exe under the CMD folder under the GIT folder this program is the GIT window management interface.
2. Install git in Linux
In Linux, run the GIT command to check that git is installed. If it is not installed, what command will be prompted for installation.
If no prompt is displayed, enter the following command to install
Sudo apt-Get install git old systems use the next
Sudo apt-Get install Git-core
Ii. Common commands
Before introducing git, we should familiarize ourselves with the command line operations.
CD command: Enter the directory example: cd e: \ A or CD ../one is to enter the directory, the other is to return to the directory
Mkdir A creates a folder
Ls-A displays all files and folders in the current directory, including hidden
Ll display all current files
PWD displays the current directory
3. Git repository 1. Configure Repository Information
The first step is to configure the following information. Because git is used for collaborative processing, everyone must have their own identity information.
Two commands.
Git config -- global user. Name "your name"
Git config -- global user. Email "your email"
We can give the name and email at will. But note that it is best to be standardized. That is to say, it is true. You can give it for testing by yourself. But it is impossible to develop it.
2. Create a warehouse in manage 2.1 create a warehouse
Git init is used to create and initialize a repository. It is an empty repository. A hidden. Git folder is generated under your directory. Do not change it. A problem occurs when it is changed.
2.2 add files to the cache
Git add file name/git add-A: Upload a single file and submit all files. For details about git add, refer to the following description.
. Submit the cached data to the warehouse
The file added by using git add is not put into the final version library. We need to use a command to put it in the final version library.
Git commit-M "comment"/git commit it is recommended that you use the first method. The first method can be used to comment out what you have modified.
3. Version rollback
Before explaining version rollback, we should be familiar with a command. Because there are a lot of files you have modified in actual development, it is impossible to remember them one by one. Therefore, you can better check the commands.
Git log/git log -- pretty = the first type of oneline displays a full point, and the second type skips unnecessary information.
Git status to check the status of the current cache zone (whether there are files and whether there are changes ...)
Git reset -- hard head ^ version rollback, using git reset command.
You can also use git log to check whether the "ID" in your version library can be returned by using the ID.
Git reset -- hard XXXX does not need to be fully written. Write a few, press the tab key on the keyboard to automatically complete.
Git reflog can view the commands you run every time. If you roll back, you regret it. you can use this command to check your ID before rollback. use git reset -- hard to roll back.
4. view the version Library and the current workspace File
If the current workspace file is modified, use add to add it to the temporary workspace. Now we are modifying the workspace content. then, when you use commit to submit the files in the temporary storage area. we can use the command to check. the current version library, which is different from the files in the work area.
Git diff head -- your file
5. Undo workspace Modification
Sometimes our workspace has been modified and added to the cache area. At this time, we have not submitted it to the version library. but there is a problem. we cannot submit. because I wrote the wrong one. what should I do now.
Git checkout-File Name: This command allows you to return any files modified in the workspace to the same state as your current version library.
This command is mainly used in two scenarios.
1. The workspace file has been modified. It has not been submitted to the temporary storage area. Using the command will return to the same status as the current version of the database.
2. The workspace file has been modified and submitted to the temporary storage area. But you have modified it again. You can use the command to restore it to the status of the temporary storage area.
Git reset head
6. Delete and Restore Files
Sometimes we need to delete the file, we can use the following command
The git rm file name is used to delete a file. The file is deleted, but you need to submit it to the final version library to delete it.
Git checkout -- if the file name is submitted above and the file is deleted incorrectly, we can use this command to restore it. As mentioned above.
Iv. remote warehouse 5. Branch Management 6. Tag Management
Use of git version control tools