Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

error: Untracked working tree file

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.

like image 954
Leem.fin Avatar asked Feb 14 '12 09:02

Leem.fin


People also ask

What does untracked file mean?

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.

What happens to untracked files?

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.


2 Answers

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.

like image 87
Peter Bratton Avatar answered Sep 21 '22 23:09

Peter Bratton


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.

like image 44
dannio Avatar answered Sep 22 '22 23:09

dannio