Git 創(chuàng)建分支
Git checkout -b 分支名稱
Git branch 查看所有分支
git merge login 合并分支 login 到當(dāng)前分支
git push --set-upstream origin login 提交新的分支
git push origin login 提交代碼到 login 分支
要將A分支的一個commit合并到B分支:
首先切換到A分支
git checkout A
git log
找出要合并的commit ID :
commit 331cdbf28fba8343511ecbd29e704611bae70298
然后切換到B分支上
git checkout B
git cherry-pick 331cdbf28fba8343511ecbd29e704611bae70298
這樣就將A分支的某個commit合并到了B分支了
希望保留本地的修改雪猪,pull之后屉佳,修改依然存在
git stash
git pull
git stash pop
解析:
git stash: 將改動藏起來
git pull:用新代碼覆蓋本地代碼
git stash pop: 將剛藏起來的改動恢復(fù)
這樣操作的效果是在最新的倉庫代碼的基礎(chǔ)仍保留本地的改動
git stash # save uncommitted changes
pull, edit, etc.
git stash list # list stashed changes in this git
git show stash@{0} # see the last stash
git stash pop # apply last stash and remove it from the list
git stash apply stash@{2}
git stash --help # for more info
這種問題是因為VSCode中咽弦,花括號在 PowerShell 中被認(rèn)為是代碼塊執(zhí)行標(biāo)識符,若想正常使用茅姜,可用反引號 進(jìn)行轉(zhuǎn)義:stash@
{0’}
git branch -r****:查看所有遠(yuǎn)程分支
git checkout 遠(yuǎn)程分支名:拉取遠(yuǎn)程分支并同時創(chuàng)建對應(yīng)的本地分支
git checkout master
git pull
git merge --no-commit --no-ff develop
要強(qiáng)制使用本地分支棘街,使用git branch -D + 分支名稱的命令刮吧。
git branch -d test_branch來刪除本地分支,
git checkout -b myRelease origin/Release
作用是checkout遠(yuǎn)程的Release分支槐秧,在本地起名為myRelease分支儒拂,并切換到本地的myRelase分支
git取消合并<u>#</u>
git merge --abort
導(dǎo)出提交記錄
git log --pretty=format:"%ai , %an: %s" --since="400day ag" --encoding="GBK" >> ~/Desktop/commit-employee-src.csv
1. git刪除遠(yuǎn)程分支
git push origin --delete [branch_name]
2. 刪除本地分支區(qū)別
git branch -d 會在刪除前檢查merge狀態(tài)(其與上游分支或者與head)寸潦。
git branch -D 是git branch --delete --force的簡寫,它會直接刪除社痛。
git remote add itiaoling <u>http://code.itiaoling.com/development/isc/frontend/oc-web.git</u>
在這里沒有看到我們想要的分支,先獲取所有分支:
git fetch
1、git update-index --assume-unchanged ${文件路徑}
2命雀、讓git不再跟蹤{文件路徑}撵儿,即可使git再次跟蹤${文件路徑}
.在工作區(qū)修改,但并未提交到暫存區(qū)(即并沒有add)狐血。
對于單個文件的撤銷修改而言淀歇,使用下面方法。
$ git checkout -- 文件名
git 刪除某個提交
git reset --soft HEAD~n ,撤銷最近n個提交匈织,變成add狀態(tài)
git stash 暫存代碼
git reset --hard HEAD~1 刪除前1一個提交
git unstash 取出代碼
git commit 重新提交代碼
git push -f 強(qiáng)制推送到遠(yuǎn)程
1. 本地分支重命名(還沒有推送到遠(yuǎn)程)
|
1
|
git branch -m oldName newName
|
2. 遠(yuǎn)程分支重命名 (已經(jīng)推送遠(yuǎn)程-假設(shè)本地分支和遠(yuǎn)程對應(yīng)分支名稱相同)
a. 重命名遠(yuǎn)程分支對應(yīng)的本地分支
|
1
|
git branch -m oldName newName
|
b. 刪除遠(yuǎn)程分支
|
1
|
git push --delete origin oldName
|
c. 上傳新命名的本地分支s
|
1
|
git push origin newName
|
d.把修改后的本地分支與遠(yuǎn)程分支關(guān)聯(lián)
|
1
|
git branch --set-upstream-to origin/newName
|
git fetch origin master //僅同步遠(yuǎn)程master分支到本地