http://learngitbranching.js.org/ is a website for learning git. It teaches novices how to use git step by step in a game mode. This article is a record of the git commands that I reviewed and learned during the game.
--------split line--------
submit:
- git commit: commit the current version
- git branch newImage: create a new branch newImage
- git checkout newImage: switch to branch newImage
- Parameter -b: Create a new branch and switch to the same time
- git merge bugFix: merge branch bugFix to current branch
- git rebase master: transplant the current branch to the Master branch and switch to the past
- git checkout commitHash: Move the HEAD to the specified commit by specifying the hash value of the commit (the first few are enough)
- git log: view commit history
- git checkout master ^: switch to the parent node of Master, HEAD is separated
- git checkout HEAD ~ 4: The current HEAD is pushed back 4 times, ~ is a relative reference
- git branch -f master HEAD ~ 3: Force to move to the parent 3 level of Master branch
- git reset HEAD ~ 1: The local temporary storage area cancels the last commit, but the code is still
- git revert HEAD: a new commit, to restore the code to the previous state
other:
- git cherry-pick c2 c4: copy the commits of c2 and c4 to the current branch
- git rebase -i HEAD ~ 4: Copy the previous 4 commits to the new branch in an interactive interface
- git commit --amend: modify this commit
- git tag v1 [C1]: tag [commit C1, default current HEAD] tag is v1
- git describe master: show <recent tag> _ <different commit times> _g <current commit hash>
Remotely:
- git clone: clone remote library
- git fetch: Get the latest commit of the remote library locally without changing other branches
- git pull: equal to git fetch + git merge origin / master pull the latest commit of the remote library and merge to the local branch
- git push: local commit push to remote repository
- git pull --rebase: merge the latest commit of the remote library to the local, the local code is appended at the end
- git checkout -b foo origin / master: create local branch foo, trace remote branch Master
- git branch -u origin / master foo: associate branch foo with trace remote branch master
- git push origin master: push the local master branch to the remote origin / master
- git fetch origin <source>: <place>: update the latest code of the remote source library to the local place library, if the place does not exist, it will be created automatically