git - 奇怪的分支合并错误,我不知道如何解决

时间:2013-02-07 06:27:56

标签: git git-merge

当我git status时,我收到此错误消息:

# 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)

所以我不能拉或推。当我拉我得到这个:

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

我该怎么做才能解决这个问题? 谢谢!

3 个答案:

答案 0 :(得分:44)

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

您还需要明确地将.DS_Store添加到.gitignore,以便将来不可避免地创建.DS_Store时,它不会妨碍您的提交。

答案 1 :(得分:1)

你可能不关心.DS_Store。 因此,尝试将其移至.DS_Store.bak并再次拉动

答案 2 :(得分:0)

我认为您需要首先添加add .然后pull然后commitpush

的文件