Paul C
Paul C

Reputation: 51

Git pull claims new local file will be overwritten

I have created a local file.

user@box:/project$ git status
On branch development
Your branch and 'origin/development' have diverged,
and have 2 and 6 different commits each, respectively.
  (use "git pull" to merge the remote branch into yours)
Changes to be committed:
  (use "git reset HEAD <file>..." to unstage)

      new file:   components/shared/some_utils.py

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

       modified:   components/shared/some_utils.py

However, when I do a pull I get this error:

error: Your local changes to the following files would be overwritten by merge:
    components/shared/some_utils.py

I have confirmed that this file is completely local is not coming in from remote. I cannot understand how or why git would overwrite it.

Upvotes: 0

Views: 194

Answers (2)

James Lockhart
James Lockhart

Reputation: 1040

If you don't wish to commit your file you can do the alternative :

git stash
git pull 
git stash apply

Upvotes: 1

Derick Alangi
Derick Alangi

Reputation: 1100

Git pull changes the position of the HEAD pointer and will over write changes you have made locally. The solution to this is that you should commit your local changes before pulling.

Do this:

git add .
git commit -m "your message"
git pull

That should work.

Upvotes: 0

Related Questions