First, install git, download the installation on the official website (the simulation environment below is WINDOW7)
Second, the basic operation:
1. Create a git library:
① First Use the mkdir command to create an empty directory, and then use git init to change the directory into a git library, where a. Git directory is created, which is hidden by default
Description: The PWD command is to display the current path
In the config file under. Git (recommended to open with notepad++), add the Save:
[User] name=ibelive [email protected]
This way, if you do not add personal information, the following actions will not work.
2. Add File to Repository
① randomly create a TXT file to test, such as testfile.txt, enter the text "This is a file.", put the file in the Testgit directory;
② Use the git add command to add a TXT file to the repository and commit using the git commit command;
Description: The-M in the git commit command is a specific description of the commit operation and can be written casually, preferably with practical meaning.
3. Update the modified file to the repository
① Modify the content information of the testfile.txt file and add "Hello world." After saving
② Use the git status command to see that the file display is modified, or you can use the git diff command to see the specific changes
③ using the git add command and the git commit command to commit the modified file
4, version of the control
You can use the git log command to get different versions of file updates, and we can use the git reset command to easily recover or return to any of these versions.
Or use git log--pretty=oneline to get
The first piece of a similar serial number of things is its version number, using git reset--hard head^ back to the previous version, git reset--hard head^^ back to the last version, and so on, if more than 100, can be written head~100. You can also return to this version based on the first few versions of the version number, which is the git reset--hard d5021714c command to return to the version of "Write Hello World".
Description: The cat command is to view the contents of a file, and you can use the Cat command to view changes to the file contents of each version recovery or return.
Version control tools--git Basic commands (1)