1、問(wèn)題描述:
出現(xiàn) Your branch and 'origin/master' have diverged,
(use "git pull" to merge the remote branch into yours)
nothing to commit, working tree clean
解決辦法:
如果不需要保留本地的修改,只要執(zhí)行下面兩步:
git fetch origin
git reset --hard origin/master
KUNdeiMac:test kun$ git status
On branch master
Your branch and 'origin/master' have diverged,
and have 3 and 3 different commits each, respectively.
(use "git pull" to merge the remote branch into yours)
nothing to commit, working tree clean
KUNdeiMac:test kun$ git branch -a
* master
remotes/origin/master
KUNdeiMac:test kun$ git fetch origin
KUNdeiMac:test kun$ git reset --hard origin/master
HEAD is now at a79252b 刪除文件.gitignore
KUNdeiMac:test kun$ git status
2、問(wèn)題描述:
當(dāng) git push 時(shí)出現(xiàn)Updates were rejected because the tip of your current branch is behind錯(cuò)誤。
【分析】:因?yàn)檫h(yuǎn)程repository和我本地的repository沖突導(dǎo)致的胜臊,而我在創(chuàng)建版本庫(kù)后鞋诗,在github的版本庫(kù)頁(yè)面點(diǎn)擊了創(chuàng)建README.md文件的按鈕創(chuàng)建了說(shuō)明文檔筒主,但是卻沒有pull到本地燥翅。這樣就產(chǎn)生了版本沖突的問(wèn)題
解決辦法:
參考:http://www.cnblogs.com/daemon369/p/3204646.html
三種解決辦法:
1.使用強(qiáng)制push的方法:
git push -u origin master -f
這樣會(huì)使遠(yuǎn)程修改丟失,一般是不可取的蜕提,尤其是多人協(xié)作開發(fā)的時(shí)候森书。
2.push前先將遠(yuǎn)程repository修改pull下來(lái)
git pull origin master
git push -u origin master
3.若不想merge遠(yuǎn)程和本地修改,可以先創(chuàng)建新的分支:
git branch [name]
然后push
git push -u origin [name]
3谎势、問(wèn)題描述:
The --set-upstream flag is deprecated and will be removed. Consider using --track or --set-upstream-to
解決辦法:
正確的本地分支關(guān)聯(lián)遠(yuǎn)程分支命令 是
git branch --set-upstream-to <remote>/<branch> <localbranch>
KUNdeiMac:test kun$ git status
On branch master
Your branch is up-to-date with 'myorigin/master'.
nothing to commit, working tree clean
KUNdeiMac:test kun$ git branch -a
* master
remotes/myorigin/master
remotes/origin/master
KUNdeiMac:test kun$ git branch --set-upstream-to origin/master
Branch master set up to track remote branch master from origin.
KUNdeiMac:test kun$
4凛膏、問(wèn)題描述:
合并pull兩個(gè)不同的項(xiàng)目失敗 ,提示:fatal: refusing to merge unrelated histories]
解決辦法:
git pull origin master --allow-unrelated-histories
5、問(wèn)題描述:
關(guān)于origin/HEAD脏榆,git可以默認(rèn)選擇哪個(gè)分支(即克隆時(shí))猖毫, 默認(rèn)情況下origin / HEAD指向的即為默認(rèn)分支,比如origin/HEAD -> origin/master 须喂,指向的origin/master即為默認(rèn)分支吁断。
解決辦法:
參考:https://stackoverflow.com/questions/354312/why-is-origin-head-shown-when-running-git-branch-r
① 您可以在GitHub repo的管理設(shè)置中更改此設(shè)置。 您也可以從命令行設(shè)置
git remote set-head origin trunk
② 或者刪除它
git remote set-head origin -d
KUNdeiMac:SKCamera kun$ git branch -a
* master
remotes/origin/HEAD -> origin/master
remotes/origin/master
KUNdeiMac:SKCamera kun$ git remote set-head origin -d
KUNdeiMac:SKCamera kun$ git branch -a
* master
remotes/origin/master
KUNdeiMac:SKCamera kun$
6坞生、問(wèn)題描述:
在執(zhí)行pod update之后build工程遇到如下提示:The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.
diff: /../Podfile.lock: No such file or directory
diff: /Manifest.lock: No such file or directory error: The sandbox is not in sync with the Podfile.lock.
Run 'pod install' or update your CocoaPods installation.
解決辦法:
① 刪除 YourProject.xcworkspace
rm -rf YourProject.xcworkspace
② 升級(jí)cocoapods
pod setup
sudo gem install cocoapods --pre
pod install