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?
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 .
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.
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.
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.
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.
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.
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.
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