標籤:錯誤 git
1、error: failed to push some refs to ‘[email protected]:XXXX/XXXX‘
hint: Updates were rejected because the remote contains work that you dohint: not have locally. This is usually caused by another repository pushinghint: to the same ref. You may want to first integrate the remote changeshint: (e.g., ‘git pull ...‘) before pushing again.hint: See the ‘Note about fast-forwards‘ in ‘git push --help‘ for details.
#解決方案:git pull --rebase origin mastergit push origin master
2、Your local changes to the following files would be overwritten by merge
error: Your local changes to the following files would be overwritten by merge: protected/config/main.phpPlease, commit your changes or stash them before you can merge.
#解決方案:如果希望保留生產伺服器上所做的改動,僅僅併入新配置項, 處理方法如下:git stashgit pullgit stash pop然後可以使用git diff -w +檔案名稱 來確認代碼自動合并的情況.反過來,如果希望用程式碼程式庫中的檔案完全覆蓋本地工作版本. 方法如下:git reset --hardgit pull其中git reset是針對版本,如果想針對檔案回退本地修改,使用git checkout HEAD file/to/restore
3、Pull is not possible because you have unmerged files
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‘.
#解決方案:查看衝突檔案1、git status也可以告訴我們衝突的檔案; Unmerged paths: (use "git add <file>..." to mark resolution) both modified: file2、手動解決衝突,然後提交更改:vi filegit add filegit commit -m ‘解決衝突‘
4、CONFLICT (content):Merge conflict in readme.txt
$ git merge feature1Auto-merging readme.txtCONFLICT (content):Merge conflict in readme.txtAutomatic merge failed; fix conflicts andthen commit the result.
#解決方案:1、git status也可以告訴我們衝突的檔案;# both modified: readme.txt #衝突檔案為readme.txt2、查看readme.txt的內容:<<<<<<<HEADmaster=======fenzhi>>>>>>> feature1Git用<<<<<<<,=======,>>>>>>>標記出不同分支的內容,我們修改如下後儲存:master and fenzhi3、再提交:$ git add readme.txt $ git commit -m "hebing"
5、The branch ‘feature-vulcan‘ is not fully merged.
error:The branch ‘feature-vulcan‘ is not fully merged.If you are sure you want to delete it, run ‘git branch -D feature-vulcan‘.
#解決方案:強行刪除,需要使用命令:git branch -D feature-vulcan。
6、Please move or remove them before you can merge. Aborting
#解決方案:git clean -d -fx ""其中 x -----刪除忽略檔案已經對git來說不識別的檔案d -----刪除未被添加到git的路徑中的檔案f -----強制運行
本文出自 “營運·人生” 部落格,請務必保留此出處http://qiangsh.blog.51cto.com/3510397/1769956
Git錯誤總結