Search code examples
gitbitbucketgit-branchgit-pushgit-pull

git push origin master error: The following untracked working tree files would be overwritten by merge: .DS_Store


It's been a while that I am facing the following problem. What's the fix to it? I am just a newbie in git so please be instructive. I have already tried to follow the commands shown in the error but wasn't successful.

Monas-MacBook-Pro:demo mona$ git branch
* master
Monas-MacBook-Pro:demo mona$ git add .
Monas-MacBook-Pro:demo mona$ git commit -m "logo fixed"
[master 62bedf3] logo fixed
 1 file changed, 8 insertions(+), 7 deletions(-)
Monas-MacBook-Pro:demo mona$ ls
1a
Monas-MacBook-Pro:demo mona$ git push
fatal: The current branch master has no upstream branch.
To push the current branch and set the remote as upstream, use

    git push --set-upstream origin master

Monas-MacBook-Pro:demo mona$ git push origin master
To https://lamiastella@bitbucket.org/lamiastella/vldb-demo.git
 ! [rejected]        master -> master (non-fast-forward)
error: failed to push some refs to 'https://lamiastella@bitbucket.org/lamiastella/vldb-demo.git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
Monas-MacBook-Pro:demo mona$ git pull origin master
From https://bitbucket.org/lamiastella/vldb-demo
 * 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
Monas-MacBook-Pro:demo mona$ git pull
There is no tracking information for the current branch.
Please specify which branch you want to merge with.
See git-pull(1) for details

    git pull <remote> <branch>

If you wish to set tracking information for this branch you can do so with:

    git branch --set-upstream-to=origin/<branch> master

Monas-MacBook-Pro:demo mona$ 

Solution

  • Those are OS X internal files. Somebody must have checked them in by mistake. Just move them to a different folder, do the merge, move back and add the .DS_Store folder to .gitignore and you should be fine.