git的使用

[config]
git config --global url."https://".insteadOf git:// 
git config --global core.editor vim
git config --global core.filemode false 
 
[create remote]
touch README.md
git init
git add README.md
git commit -m "first commit"
git remote add origin git@github.com:Aceaura/aura.git
git push -u origin master 
 
[delete repo]
git remote rm origin
 
[delete remote branch]
git push -u origin :dev 
git push -u origin --delete dev
 
[delete remote commit]
git push -u origin :dev
git push -u origin dev:dev 
 
[delete local branch]
git branch delete -d dev
 
[delete local commit no remote]
git reset  dev~1 
 
[delete local commit with remote]
git push -u origin :dev 
git checkout  dev
git reset dev~1
git push -u origin dev:dev 
 
[diff two commit]
git diff da985 b325c
 
[diff  HEAD to workspace]
git diff HEAD
 
[diff branch to workspace]
git diff maint
 
[diff  HEAD to stage]
git diff --cached
 
[diff stage to workspace]
git diff
 
[checkout HEAD]
git checkout HEAD
 
[checkout branch]
git checkout dev
 
[checkout commit]
git checkout da985
 
[checkout commit and add new branch]
git checkout da985 -b new
 
[rollback branch]
git checkout new
git reset new ~1 --soft
 
[reset stage and workspace to commit]
git reset  da985 --hard  
 
[reset stage and workspace to HEAD]
git reset
 
[merge branch to HEAD and reset HEAD]
git merge dev
 
[copy and merge commit  to HEAD and reset HEAD]
git cherry-pick da985 
 
[lenear  copy and merge HEAD  to branch, and reset HEAD] 
git rebase dev
 
[handle conflict from branch to HEAD]
git add .
git commit
 
[cut one branch and paste to another]
git rebase --onto new_base old_base target_branch
 
[change commit sequence]
git rebase -i base_commit
 
[solve confict in rebase]
git add .
git rebase --continue
 
[back to time before rebase when conflicted]
git reabase --abort
 
[abandon branch when conflicted]
git reabase --skip 
 
[figure out what you have done in workspace] 
git status 
 
[clean not track files]
git clean -n 
git clean -df 
 
[rename]
git mv old_file new_file
 
[tag head a version]
git tag -a "v1.3.7" -m "version 1.3.7" 
 
[show all tags]
git tag
 
[show revise in one tag] 
git show v1.3.7 
 
[git stash pop conflict]
git add file_name
git commit 
git stash clear
 
[git push tag]
git push origin tag_name
原文地址:https://www.cnblogs.com/neyer/p/4520002.html