Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git warning of file overwriting due to (supposedly) untracked files

Tags:

git

Attempting to pull from git repo, but getting the following output. I think these files are tracked (As they should be), but its indicating that they are not. They are not in .gitignore. I am about 5-10 commits behind the branch.

git pull --rebase origin master
From github.com:user/Project
 * branch            master     -> FETCH_HEAD
First, rewinding head to replay your work on top of it...
error: The following untracked working tree files would be overwritten by checkout:
mountdoom/protected/models/UserHelper.php
mountdoom/protected/models/UserRegistrationForm.php
mountdoom/protected/runtime/state.bin
mountdoom/protected/views/site/register.php
Please move or remove them before you can switch branches.
Aborting
could not detach HEAD

Any ideas how to resolve this?

like image 464
DJSunny Avatar asked Oct 03 '11 03:10

DJSunny


People also ask

How do I fix nothing added to commit but untracked files?

To fix this error, either add the files causing the error to the staging area or ignore them using the . gitignore file.

How do I make git not show untracked files?

You can use the git clean command to remove untracked files. The -fd command removes untracked directories and the git clean -fx command removes ignored and non-ignored files.

Why is my file untracked git?

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

They're tracked in the version you're checking out, but not in the version you had checked out previously. If you don't care about the untracked versions, just remove them.

If you do care about them, commit them before doing the rebase. You may then have to merge as part of the rebase process.

like image 71
Matthew Flaschen Avatar answered Oct 19 '22 02:10

Matthew Flaschen


You can add the untracked files to the index (git add), git stash them, then do your git pull --rebase and then git stash pop and resolve conflicts if any.

like image 42
manojlds Avatar answered Oct 19 '22 02:10

manojlds