1、問題描述:
出現(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、問題描述:
當 git push 時出現(xiàn)Updates were rejected because the tip of your current branch is behind錯誤。
【分析】:因為遠程repository和我本地的repository沖突導致的,而我在創(chuàng)建版本庫后,在github的版本庫頁面點擊了創(chuàng)建README.md文件的按鈕創(chuàng)建了說明文檔,但是卻沒有pull到本地。這樣就產(chǎn)生了版本沖突的問題
解決辦法:
參考:http://www.cnblogs.com/daemon369/p/3204646.html
三種解決辦法:
1.使用強制push的方法:
git push -u origin master -f
這樣會使遠程修改丟失,一般是不可取的,尤其是多人協(xié)作開發(fā)的時候。
2.push前先將遠程repository修改pull下來
git pull origin master
git push -u origin master
3.若不想merge遠程和本地修改,可以先創(chuàng)建新的分支:
git branch [name]
然后push
git push -u origin [name]
3、問題描述:
The --set-upstream flag is deprecated and will be removed. Consider using --track or --set-upstream-to
解決辦法:
正確的本地分支關聯(liá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、問題描述:
合并pull兩個不同的項目失敗 ,提示:fatal: refusing to merge unrelated histories]
解決辦法:
git pull origin master --allow-unrelated-histories
5、問題描述:
關于origin/HEAD,git可以默認選擇哪個分支(即克隆時), 默認情況下origin / HEAD指向的即為默認分支,比如origin/HEAD -> origin/master ,指向的origin/master即為默認分支。
解決辦法:
參考:https://stackoverflow.com/questions/354312/why-is-origin-head-shown-when-running-git-branch-r
① 您可以在GitHub repo的管理設置中更改此設置。 您也可以從命令行設置
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、問題描述:
在執(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
② 升級cocoapods
pod setup
sudo gem install cocoapods --pre
pod install