git一些基本操作
阿新 • • 發佈:2018-11-21
1.建立一個branch
檢視當前已經存在的branch
git branch
git remote -v
建立一個新的branch在伺服器上
git push upstream dev
將自己的origin和server的upstream關聯後,才能通過 git fetch upstream 來將server上最新的code更新到自己的origin
git remote add upstream
http://192.168.1.186/bigdata/mojing-server.git
2.git之http方式設定記住使用者名稱和密碼
git config --global credential.helper store
3.提交程式碼到<branch name>
從platform/upstream更新程式碼
git fetch upstream
git rebase -i upstream/<branch name>
將所有發生變化的檔案新增到提交佇列中
git add .
提交程式碼
git commit -m “提交說明”
git push origin <branch name>
4.從remote上取一個新的branch到本地
git checkout -b <branch name> upstream/<branch name>
git push origin <local branch name>:<branch name>
5.merge branch a into b
git checkout <branch b>
git fetch upstream
git rebase -i upstream/<branch b>
git merge --no-ff upstream/<branch a>
git push origin <branch b>
git update-index --assume-unchanged <具體檔案全路徑>
git update-index --no-assume-unchanged <具體檔案全路徑>
git stash pop
6.強制退回到某次提交
切換branch
git checkout <branch>
檢視提交日誌
git log
退回到某次提交
git reset --hard <提交的編號>
7.刪除伺服器上的版本
git push origin --delete <branch name>
git checkout -b <new branch name> <from where>
git remote add
http://192.168.1.186/platform/mojing-csp.git
git fetch upstream
git checkout -b upstream-dev upstream/dev
git push origin upstream-dev:dev
git checkout -b dev origin/dev