git - strange branch merge error that I am not sure how to solve

江枫思渺然 提交于 2019-12-04 16:37:00

问题


When I git status, I get this error message:

# On branch master
# Your branch and 'origin/master' have diverged,
# and have 1 and 2 different commits each, respectively.
#
# Untracked files:
#   (use "git add <file>..." to include in what will be committed)
#
#   .gitignore
nothing added to commit but untracked files present (use "git add" to track)

So I can't pull or push. When I pull I get this:

macoss-MacBook-Pro-10:Marketing owner12$ git pull origin master
Password for 'https://genadinik@bitbucket.org': 
From https://bitbucket.org/genadinik/marketing
 * branch            master     -> FETCH_HEAD
error: The following untracked working tree files would be overwritten by merge:
    .DS_Store
Please move or remove them before you can merge.
Aborting

What can I do to resolve this? Thanks!


回答1:


rm .DS_Store
git add -A
git commit -m "Added .gitignore file"

You'll also want to expressly add .DS_Store to your .gitignore so that when .DS_Storeis inevitably created in the future, it won't get in the way of your commits.




回答2:


You probably don't care about .DS_Store. So, try to move it to .DS_Store.bak and pull again




回答3:


I think you need to first add the files with add . then pull then commit and push



来源:https://stackoverflow.com/questions/14744993/git-strange-branch-merge-error-that-i-am-not-sure-how-to-solve

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!