商業(yè)網(wǎng)站策劃書范文網(wǎng)站優(yōu)化排名推廣
origin/<branch>
遠(yuǎn)程分支在本地以 origin/<branch>
格式存在,他指向上次和遠(yuǎn)程分支通過時(shí)的記錄
git checkout origin/<branch>
會(huì)出現(xiàn)HEAD分離的情況
與遠(yuǎn)程通訊
git fetch —— 從遠(yuǎn)端獲取數(shù)據(jù)(實(shí)際上將本地倉庫中的遠(yuǎn)程分支更新成了遠(yuǎn)程倉庫相應(yīng)分支最新的狀態(tài))
- 從遠(yuǎn)程倉庫下載本地倉庫中缺失的提交記錄
- 更新遠(yuǎn)程分支指針(如 o/main)
使用 http:// 或 git:// 協(xié)議從遠(yuǎn)端獲取數(shù)據(jù)
注意:git fetch 不會(huì)修改你本地的分支
牢記下面兩個(gè)公式,以后經(jīng)常會(huì)使用到
git pull = git fetch + git merge o/<branch>
git pull --rebase = git fetch + git rebase o/<branch>
提交的技巧:
git checkout branchName commitID
將branchName指向指定的提交記錄
跟蹤遠(yuǎn)程分支
git checkout -b totallyNotMain o/main
通過遠(yuǎn)程分支切換到一個(gè)新的分支
翻譯: 新創(chuàng)建一個(gè)分支為totallyNotMain分支
并設(shè)置它的remote tracking
為: o/main
意味著為 totallyNotMain分支指定了推送的目的地以及拉取后合并的目標(biāo)為o/main
上面的是設(shè)置遠(yuǎn)程追蹤分支的其中一只方法,接下來介紹另外一種方法:
git branch -u o/main foo
如果當(dāng)前就在 foo 分支上, 還可以省略 foo:
git branch -u o/main
詳細(xì)介紹幾個(gè)操作遠(yuǎn)程分支的命令的參數(shù)
git push
- 不加參數(shù)時(shí):根據(jù)上面我們說的追蹤分支來確定遠(yuǎn)程的目的地
git push <remote> <place>
git push origin <source>:<destination>
舉例:git push origin main
翻譯: 本地倉庫中的“main”分支,獲取所有的提交,再到遠(yuǎn)程倉庫“origin”中找到“main”分支,將遠(yuǎn)程倉庫中沒有的提交記錄都添加上去,搞定之后告訴我。
注意:我們執(zhí)行push命令的過程中,當(dāng)前分支(HEAD)不會(huì)移動(dòng)。