1,添加文件到版本庫
添加單個文件: git add filename
添加全部txt文件: git add *.txt
添加全部修改文件: git add .
2,提交
提交全部修改: git commit -m "commit msg" -a
提交單個修改: git commit -m "commit msg" filename
修改commit信息: git commit --amend
3,撤銷修改
撤銷還沒有提交的修改: git checkout 1.txt 2.txt
撤銷提交: git revert head(反轉提交,撤銷最近一次的提交而且會產生一個新的commit信息)
復位: git reset HEAD filename(取消暫停)
git reset --hard HEAD^(撤銷)
4,分支
列出本地分支: git branch
列出全部分支: git branch -a
基於當前分支建立新分支: git branch branchcname
切換分支: git checkout branchname
基於當前分支建立新的分支而且切換到新的分支: git checkout -b branchname
基於某次提交,分支或者tag建立分支: git branch branchname bf357de
git branch branchname tagname
5,合併
普通合併: git merge branchname
挑選合併: git cherry-pick bf357de
壓縮合並: git merge --squash branchname
其它: git rebase branchname
reabse: git rebase -igit
6,刪除分支
git branch -d branchname
git branch -D branchname(強制刪除分支)
7,查看狀態
git log --oneline --graph
gitk 查看當前分支歷史
gitk branchname 查看特定分支歷史
gitk -all 查看全部分支歷史
gitk filename 查看某文件的歷史記錄
8,remote
git clone
git pull origin branchname
git push origin branchname
git push origin tagname
9,config
生成ssh密鑰: ssh-keygen.exe -t rsa
配置郵箱: git config --global user.email *****.com
配置用戶名: git config --global user.name your-id
ssh