1.1. Git
1. The version is rolled back;
Git reset --hard hashno; git commit and then fall back to the previously submitted version;
Git reset --hard HEAD; Restore the latest push version and discard this modification;
Git reset HEAD hashno; restore the previous version of the push, save the local temporary changes;
Git reset HEAD~
2. Version storage:
Git stash, used to save the local version without submitting to the remote code repository;
Git add -a ;git stash;
Git stash list View storage records;
Git stash apply {name}, do not specify the name default reply is the most recent storage
If you have made changes, you can't directly apply. The simple method is to reset once and then execute the above command.
3. Output local modification patch patch
Git diff > diff.patch // compare staging and local differences;
Git diff --cached // compares warehouse and local differences;
Git apply diff.patch // Premise must be on the same version
4. Git push [origin remote server] [master remote branch]
VCM: git push http://xxxx/VCM.git HEAD:refs/for/master
gpusp_face: git push http://xxx/gpusp_face.git HEAD:refs/for/master
5. Git revert / / restore the version of the already pushed;
6. The code review found that the code needs to be modified, what needs to be done:
{ gerrit page abandon ;
Git reset HEAD~: Undo local latest commit (retain workspace modification)
Git reset HEAD~2: Undo the last two commits (retain workspace modifications), and so on
Git commit --amend -m [message]: If you only want to modify the latest commit, you can modify the code locally. If there is no change in the code, the above command can be used to rewrite the information submitted by the last commit.
}
7. Git create a local branch
{ git branch -a View all branches
Git branch new_branch //Create a local new branch
Git checkout new_branch //switch local branch
Git branch --set-upstream-to //Command to establish trace relationship between local branch and remote branch
Git pull origin master //Get the remote specified branch
}
8. Git pull and local conflict resolution
{ (1) Store local modifications first
$ git stash
All local modifications are temporarily stored.
Where stash@{0} is the tag just saved.
(2) pull content
After temporarily saving the local modification, you can pull it.
$ git pull
(3) Restore the temporarily stored content
$ git stash pop stash@{0}
The system prompts for similar information as follows:
Auto-merging c/environ.cCONFLICT (content): Merge conflict in c/environ.c
This means that the system automatically merges the modified content, but there are conflicts and conflicts need to be resolved.
(4) Resolve the conflicting part of the file
}