This article summarizes some common git operations and commands.
Create a version library, that is, create an empty directory in your local directory. Here is newgit (of course, the following is the premise of installing git, google)
Right-click the newly created directory newgit and select git Bash here.
Git init // change this Directory into a git-managed repository. Git builds the repository in an instant and adds one more. GitDirectory, which is used by git to track and manage version libraries. You must never manually modify the files in this directory. Otherwise, the GIT repository will be damaged.
Git add readme.txt (File Name) // Add the file to the repository
Git Add. // Add all files in the directory, including files in subdirectories, to the repository.
Git commit-M "Submit description" // submit the file to the repository
For operation instructions on ADD and commit, see
Git status // view the current status of the Repository
Git diff readme.txt (File Name) // view the file modification content
Git log // display the most recent commit log
Git log -- pretty = oneline // simplify the information displayed by git log, only displaying the commit ID and modification content
Git reset -- hard head ^ // return to the previous version of the current version. The head Pointer Points to the current version, and the head ^ points to the previous version of the current version, head ^ points forward to two versions. If the first 100 versions are used, use head ~ 100
Git reset -- hard (commit ID) // return to the specified version
Git reflog // view each command
Git diff head -- readme.txt (File Name) // view the difference between the latest version in the workspace and the version Library
Git checkout -- readme.txt (File Name) // undo all the modifications to the readme.txt file in the workspace. There are two situations: readme.txt has not been put into the temporary storage zone after modification. Now, the state of "undo Repair" and "recovery" is the same as that of "Slave Database". The readme.txt has been added to the temporary storage area and modified. Now, the Undo modification is returned to the state after being added to the temporary storage area. In short, this file is returned to the last timeGit commitOrGit addStatus.
Git reset head readme.txt (File Name) // unstage the modification of the temporary storage area and put it back into the workspace.
Git RM readme.txt (File Name) // delete the file from the version library. If the workspace is deleted by mistake, you can also use git checkout -- readme.txt (file name) restore the accidentally deleted file to the latest version (because there are still files in the version library)
It's just a few simple operations ~
Reference blog http://www.liaoxuefeng.com/wiki/0013739516305929606dd18361248578c67b8067c8c017b000
Next remote Repository
Learning and summarizing git (2)