git finishing (b)

Git

Rollback Versions

# Commit retreat back version of 
# the middle of the string corresponding to the length of six submitted id of the first six log information
# 100 online rollback git version of the RESET --hard the HEAD ~ $ 100
$ git the RESET - the HEAD ^ Hard
the HEAD iS AT the third time now submit c338f61 # fall back to the specified version $ git the RESET --hard cac83a the HEAD iS AT cac83a7 now second submission instructions # View used $ git reflog cac83a7 (the HEAD -> Master) the HEAD @ {0}: RESET: Moving to cac83a c338f61 the HEAD. 1} {@: RESET: Moving to the HEAD ^ 99d4ce1 the HEAD @ {2}: the commit: fourth submitted c338f61 HEAD @ {3}: commit : third submission cac83a7 (HEAD -> master) HEAD @ {4}: commit: second submission 77c2b2c HEAD @ {5}: commit (initial): first submitted












Git submission process

We must first understand the submission process git git add first step is to add the files into it, in fact, is to modify the files added to the cache area; second step is to submit the changes with git commit, in fact, all the temporary area submit to the local repository. 
When you create a Git repository, Git automatically creates a master branch, so, now, git commit is to commit the changes to the master branch.

Modify management


# View a file
$ CAT a.txt
aaaaaaaaaaa
after # modified file to view
$ CAT a.txt
aaaaaaaaaaa
BBBBB
#add to cache
$ git the Add a.txt
# then modify the file
$ CAT a.txt
aaaaaaaaaaa
BBBBB
CC
# to directly commit local repository
$ git commit -m "third submission"
[Master a4c3eaf] third submitted
1 File changed, 1 Insertion (+)
# View a.txt state at this time is not added or modified submitted, this is because, commit only to commit add to the file cache to a local warehouse, so long as the modified file, they have to add another commit, a safety mechanism which is also the Git #git diff comparison modify your modified files will be clearly marked out git diff $ diff - git A / learn2 / a.txt b / learn2 / a.txt index 776474b..a8ff3e8 100644 --- A / learn2 / a.txt +++ b / learn2 / a.txt @@ - 4,3 +4,4 @@ ccccccc








ddddddddd
eeeee
fffff
+gggg

Undoing Changes


You write code, written submission, and suddenly found himself wrong, and this time you need to roll back what
# to modify commit
$ CAT a.txt
aaaaaaaaaaa
bbbbbbbb
CCCCCCC $ git "Third submitted" the commit -m [ master a4c3eaf] third submitted 1 file changed, 1 insertion (+ ) and then modify a file $ CAT a.txt aaaaaaaaaaa bbbbbbbb CCCCCCC ddddd added to the cache area $ git add a.txt fallback version $ git checkout - a. txt until then view a file $ CAT a.txt aaaaaaaaaaa bbbbbbbb CCCCCCC found fallback version before the amendment and then modify a file $ CAT a.txt aaaaaaaaaaa bbbbbbbb CCCCCCC ddddd added to the cache area $ git add a.txt






























View the status of a file has been found that the buffer can be added to the state submitted
$ git Status
the On Branch Master
Changes committed to BE:
(use "git Restore --staged <File> ..." to unstage)
      Modified: a.txt
with command git reset HEAD <file> can modify the staging area off of revocation (unstage), back into the work area:
$ git the RESET the HEAD a.txt
unstaged Changes the After the RESET:
M learn2 / a.txt
view the status of a file found not added to the state cache can add
$ git status
the On Branch Master
Changes not staged for the commit:
(use "git the Add <File> ..." to Update the What committed by Will bE)
(use "git Restore <File> .. . "to discard Changes in Working Directory)
      Modified: a.txt NO Changes added to the commit (use" git the Add "and / or"git commit -a")


 

Guess you like

Origin www.cnblogs.com/liudongshuai/p/11571681.html