Git 一些錯誤的解決方法

注:Git初學者的我的經驗記錄,僅供參考html


1. Pull is not possible because you have unmerged files.git

症狀:pull的時候app

$ git pull
ide

Pull is not possible because you have unmerged files.
Please, fix them up in the work tree, and then use 'git add/rm <file>'
as appropriate to mark resolution, or use 'git commit -a'spa

應該是由於local文件衝突了orm

解決方法:htm

引用——blog

ci

1.pull會使用git merge致使衝突,須要將衝突的文件resolve掉 git add -u, git commit以後才能成功pull.rem

2.若是想放棄本地的文件修改,可使用git reset --hard FETCH_HEAD,FETCH_HEAD表示上一次成功git pull以後造成的commit點。而後git pull.
注意:

git merge會造成MERGE-HEAD(FETCH-HEAD) 。git push會造成HEAD這樣的引用。HEAD表明本地最近成功push後造成的引用。

就個人經驗,有時候會莫名其妙地出現這種情況,並且Untracked files 還特別多(實際上本身可能只改了一兩個文件),因此只好先保存好本身肯定作出的local的修改,而後用git reset --hard FETCH_HEAD回到上次成功pull以後的點,而後再pull就沒有問題了


2.You are not currently on a branch.

症狀:有一次pull的時候又出現衝突,這回用「git reset --hard FETCH_HEAD」方法都不行了,出現:

$ git pull
You are not currently on a branch, so I cannot use any
'branch.<branchname>.merge' in your configuration file.
Please specify which remote branch you want to use on the command
line and try again (e.g. 'git pull <repository> <refspec>').
See git-pull(1) for details.

解決方法:

首先git checkout -b temp

其次git checkout master

便可恢復到master repository的狀態,而後就能夠pull了


參考:

http://skywhsq1987.iteye.com/blog/1814137

http://slacy.com/blog/2011/04/git-pull-says-you-are-not-currently-on-a-branch/

http://ddmytrenko.blogspot.com/2012/03/git-not-currently-on-any-branch.html

相關文章
相關標籤/搜索