Tutorial from: git tutorial (Liaoche's official website)
Main command:
--pretty=--hard head^ #回退到上一版本 3628164 #回退到版本3628164$ git reflog #查看提交过的命令
5. Version fallback
5.1 Repo will record each submitted version, and the user can return to any version at any time. For example, the following three versions of Readme.txt
Version 1:wrote a Readme file
free software.
Version 2:add distributed
free software.
Version 3:append GPL
free software distributed under the GPL.
5.2. If you can't remember the versions, you can use git log to view the comment of the version submission, which is the string after the-m parameter.
$ git logcommit 3628164fb26d48395383f8f31179f24e0882e1e0author:michael Liao<[email protected]>Date:tue - the: One: the -+0800Append gplcommit ea34578d5496d7dd233c827ed32a8cd576c5ee85author:michael Liao<[email protected]>Date:tue - -: -: A -+0800add distributedcommit cb926e7ea50ad11b8f9e909c05226233bf755030author:michael Liao<[email protected]>Date:mon + -:Wuyi: - -+0800wrote a readmefile
5.3. There are two ways of fallback:
5.3.1. Fallback to previous version
$ git reset--hard head^ HEAD is now atea34578 Add distributed
5.3.2. Fallback to the specified version (via commit ID)
36281643628164 Append GPL
5.4. If you do not remember the commit ID, you can use Git reflog to query the history of the submitted version
$ git reflogea34578 [email protected]{0}: reset:moving to head^3628164 [email protected]{ 1 }: Commit:append GPLea34578 [email protected]{2}: Commit:add distributedcb926e7 [email protected ]{3file
6. Workspaces and Staging Area
Workspace refers to the directory where code is written
The workspace has a hidden directory. Git, Git's repository
There are stage and master areas in the repository, respectively, staging area and Main branch
Store changes in git add in the stage
The contents of the current version are stored in master
Git commit is to apply the changes in the stage to master
Git tutorial Learning (ii)