Sasha
Sasha

Reputation: 8705

Git - error: Untracked working tree file would be overwritten by merge. Aborting

I am new to git and left to work with live server.

After few successful git pull actions, on the latest one I got this error:

error: Untracked working tree file 
'www/files/userphotos/styles/100x100/noavatar.png' would be overwritten by merge.  Aborting

I tried git stash, but nothing happen - the error on git pull is still there.

How can I perform git pull and not mess anything on the server?

Upvotes: 0

Views: 2052

Answers (1)

CodeWizard
CodeWizard

Reputation: 141946

You need to do git add before the git stash

# Add the file to the staging area
git add . -A (alias for git add . && git add -u .)

# stash changes
git stash

# opull server updates
git pull

Use git worktree

git worktree allow you to work on different branches at the same time, Here you can see that one folder is "dirty" while the second one isn't

They both using the same (single) repository

enter image description here


If you use rebase later on:

  • Note: (Since Git 2.7)
    you can also use the git rebase [--no]-autostash as well.

Upvotes: 2

Related Questions