通常多人協做的項目都有一個remote公共倉庫,一個origin私人倉庫,一個本地倉庫。
下圖是我的根據公司中git的使用,總結三個庫與本地代碼的關係圖。git
git branch -a
git fetch --all
git remote -v
git remote add us XXX.git
git remote -v 查看本地分支的全部遠程倉庫
git branch -a
git pull us master
複製代碼
git status
git add XXX1 XXX2
git status
git commit -m "commit msg"
git push -u origin mastername 最好指定分支
then take a merge request to remote us
複製代碼
git status
git stash list
git stash save "save msg" 緩存於堆棧
git status
git checkout master
git pull us master
git checkout branch1
git rebase master 將本身的commit放在master的commit後
git push origin XXX push到私人倉庫的XXX分支
git stash pop 改動的stash pop回來;
複製代碼
add到stage後撤回:
git add xxx xxx 若想撤回
git reset HEAD xxx xxx
git status
commit到倉庫以後撤回:
git commit -m "commit msg"
git reset --soft HEAD^
若commit2次或屢次
git reset --soft HEAD~2
push到私人倉庫撤回:
git reset HEAD~2
git status
git push 會報錯
git push origin qcs_bucket --force
git status
複製代碼
git checkout -b newBranchName
git status
git log
git diff
git stash list
git stash pop
git config --global --edit 修改配置文件 hostname等;
複製代碼
git 的使用大部分須要本身真正碰到這樣的問題,去解決了而後做總結,可能會更深入吧,反正之前就開始用的,可是由於不涉及團隊協做,每次commit都是整個項目一塊兒push,而後每次都須要解決衝突,就算對了,也不知道爲何是對的。緩存