Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

The following untracked working tree files would be overwritten by merge, but I don't care

On my branch I had some files in .gitignore

On a different branch those files are not.

I want to merge the different branch into mine, and I don't care if those files are no longer ignored or not.

Unfortunately I get this:

The following untracked working tree files would be overwritten by merge

How would I modify my pull command to overwrite those files, without me having to find, move or delete those files myself?

like image 732
CQM Avatar asked Jul 01 '13 12:07

CQM


People also ask

Why do I have untracked files in git?

Untracked files are those that are in the repo's directory but have not yet been added to the repo's index with git add .

Can you overwrite merge?

The “Your local changes to the following files would be overwritten by merge” error occurs when you try to pull a remote repository to your local machine whose contents conflict with the contents of your local version of the repository. To fix this error, either stash your changes away for later or commit your changes.

What does untracked working tree files would be overwritten by Merge mean?

It throws away all staged and unstaged changes. The error: the following untracked working tree files would be overwritten by merge is triggered when we are trying to pull a remote branch while on a local one. The projects may be identical, but the local one needs to be able to track the remote for it to pull successfully.

Why am I getting “untracked working tree” error?

The reason is probably because you didn’t clone the repository. In my case, I already had some local files, so instead of running git clone, here’s what I did: If you try to git pull origin <branch-name>, you might get the “untracked working tree” error.

Why are my files of interest (FOI) blocking a merge?

The files of interest (FOI) that we are going to remove: and are blocking the merge because they are present and untracked in your working directory. The files of interest (FOI) that we are going to remove: and are blocking the merge because they are present and untracked in your working directory.

How can I pull changes from local files without losing files?

One way to do this is by stashing you local changes and pulling from the remote repo. In this way, you will not lose your local files as the files will go to the stash. For those who don't know, git ignores uppercase/lowercase name differences in files and folders.


1 Answers

The problem is that you are not tracking the files locally but identical files are tracked remotely so in order to "pull" your system would be forced to overwrite the local files which are not version controlled.

Try running

git add *  git stash git pull 

This will track all files, remove all of your local changes to those files, and then get the files from the server.

like image 103
userFog Avatar answered Sep 22 '22 09:09

userFog