0

I'm trying to git pull origin master but I'm having a problem with a local files. This local file already is in my gitignore but i'm still having this error:

error: Your local changes to the following files would be overwritten by merge

I tried:

The second attemps returned:

error: Entry 'myfolder/myfile' not uptodate. Cannot merge.
fatal: Could not reset index file to revision 'origin/master'.

My output from git status:

On branch master
Your branch is behind 'origin/master' by 119 commits, and can be fast-forwarded.
  (use "git pull" to update your local branch)

nothing to commit, working tree clean
PedroSG
  • 466
  • 2
  • 9
  • 38

3 Answers3

0

I was able to pull by deleting my file that was causing the problem but that's really not the best solution.

PedroSG
  • 466
  • 2
  • 9
  • 38
0

for the future, the problem was caused by that local file being changed, you can use git stash in order to temporarily store the changes and use git pull to get the remote version, then use git stash pop to return the local file to the changes you had.

in terms of the file being in the git ignore, you would need to run git rm --cached for the changes to be ignored if you added to the .gitignore after you made the changes

dalton
  • 11
  • 1
  • 4
0

To perform git pull, we need to use the following commands. We also need to delete or undo the local changes in order to Pull for overwriting the local files. And after deleting the local changes with the help of git command, we again need to perform the git pull command in order to overwrite the local files from git.

Here are the commands that you can use to perform these tasks:

  1. $git stash --include-untracked
  2. $git clean -fd
  3. $git pull

These commands will save the local changes on stash, then delete local changes from the git directory and then pull the files from git.

Vibhor Goyal
  • 110
  • 10