tag
git tag -d <tag name>
git push origin :refs/tags/<tag name>
git push origin --delete <tag name>
push the delete operation to the remotegit tag -a <tag name> <commit number> -m <tag commit message>
git show <tag name>
to display the tag info along with the commit info
basic
Config user name and email git config --global user.name / user.email “”
git config --list
check git config listpwd show
the catalog of repogit init
chan’ge the catalog to a repo which git can manage
SSH binding computer ssh-keygen -t rsa -C "your email@example.com"
git config --remove-section gui
reset gui settings
diff
git diff
show all the changes with detailgit diff --name-only
show all the changed file namegit diff --name-status
show only names and status of changed filesgit diff --unified=0
git diff -U0
only show the changed lines
show
show
is used for a certain commit, while log is for getting a history
git show commit number
display the changes of a given commitgit show-branch <branch 1> <branch 2>
log
git log --name-status
show history list with file name and statusgit log -p <file path>
show history list of the given filegit log --follow -p <file path>
show the enitre history(including rename ) of the given filegit log -L <start line number>,<end line number>:<file path>
show a history list of the limited lines of the given filegit log <commit number> -L <line number>,<line number>:<file path>
show a history list of the limited lines of the given file of the given commit
git log --all
show all the branch commitsgit log --author=<author name>
show a history list made by the given authorgit fetch --all && git log <origin/branchName>
get the repo state from remote and show the given branch commit historygit status
git log --date=relative|local|default|iso|iso-strict|rfc|short|raw
to change date formats
git log --grep=helloworld
search for commit tipsgit log -S 'helloworld' --source --all
search for commit code
git log -G “^(\s)function foo[(]){$” –source –all
revert && reset
git revert "commit number"
revert to a given commitgit reset "commit number"
revert to a given commit, and the commits after the given commit will be deletedgit reset HEAD^
git reset --hard origin/feat-windows
setting branch to match remote exactlygit push origin +<commit>:master
revert to a certain commit, and force push to the remote
remote
git remote -v
remote listgit remote add/rm origin [repo name]
add or remove a remote repo addressgit remote set-url origin [repo name]
update the existing remote when add a remote that say which already existgit fetch download from remote
push
git add [file] && git commit -a || git commit -m “message”&& git push
git commit --amend -m ""
ammend the last commit mesggit push –u origin [branch name]
push local file to remotegit push origin [branch name]
push the last altered file to remote when local made a submitgit push -u origin [branch name] -f
update forciblygit push origin [branch name]
submit the content that altered by branchgit add --patch <filename>
break down the given file into thunks, and choose thunks to commit
branch
git branch -r --list
git branch -a
all the branchsgit branch --show-current
git branch -m <new name>
alter branch namegit branch -d <new name>
delete branch name locallygit branch -D <new name>
delete branch name remotelygit clone -b <branch> <remote_repo>
checkout
git checkout -d [branch name]
delete a branch locally, so need push to remotegit checkout -D [branch name]
delete a branch locally, to force deleting the branch without checking merged statusgit push [repo name] --delete [branch name]
delete a branch both locally and remotelygit checkout [branch name]
switch to a branchgit checkout -b [branch name]
switch to a branch, if the repo doesn’t have the branch then the branch will be created and switched togit checkout .
clean unstaged changes made in the current branchgit checkout <file path>
clean the change of a specific file in the current branchgit checkout <branch name> <file path>
to revert a single file according to branchgit checkout <commit number> <file path>
to revert a file according to previous commitget a file from another branch or another commit and then put it into another path
git checkout <branch name> <file name>
、git checkout <commit num> <file name>
get filegit mv <old file name> <new file name>
copy and movegit reset <old file name>
reset the original file
git push --set-upstream origin [branch name]
To push the current branch and set the remote as upstream
cherry-pick
git cherry-pick <commit -number>
to apply a specific commit to the current branchgit cherry-pick -n <commit -number>
to apply a specific commit to the current branch without commit automaticallygit cherry-pick -v <branch name 1> <branch name 2>
merge
git merge <branch name or a commit num>
to merge with the given branch or commitgit merge <branch name> --allow-unrelated-histories
to merge two branchs no common basesgit merge-base <target branch> <refer branch>
compare the two branchs and show the common base
clean
git clean -f
remove untracked filesgit clean -fd
remove untracked directrons
pull
git pull --all
fetch
git fetch --all
get all the change of all the branchs
config
git config --global gui.encoding utf-8
setgui
encodingas utf-8
Exit editor
press i
to enter insert mode, ESC
(exit the inset mode)
write :WQ
(write & quit) and press enter