When I git pull origin development
, I got error:
error: Untracked working tree file '<path-to-file>' would be overwritten by merge
The reason is because one file which is in the remote development branch
is not put to git in my local project (I don't want that file in version control, so did git rm
). But on remote development
, that file is exit for version control
How to resolve this problem? Basically, I want the remote branch also remove the file from version control.
Untracked files are files that have been created within your repo's working directory but have not yet been added to the repository's tracking index using the git add command.
Untracked files are the ones still not versioned—”tracked”—by Git. This is the state of new files you add to your repository. That basically means Git is aware the file exists, but still hasn't saved it in its internal database.
To resolve your immediate problem, you should make a backup of the local file, remove the original, pull from the remote branch, and then git rm (followed by a push, to make sure the remote repo deletes the file as well). Then you can put the backup file back locally, and add a line to your .gitignore file.
This is happening due to an untracked file will be overwritten by a new file coming in from the pull request
My suggestion would be to:
git add .
git stash
git pull
Basically adding the files that aren't tracked into your git repo and stashing them away and pulling in the new version.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With