Running a git pull
created some untracked files in my local copy. The files were moved on the remote, but the pull didn't remove the files in my working directory. I've spent quite a bit of time researching this, but can't find any similar cases. Is this intended behavior, am I missing something, or both?
I made a patch and sent it to the devs of an open source project, but then I wanted to remove my local commit and git pull
the "official" patch once it got committed on the remote. So I did a bunch of "stuff" to reset to the previous official HEAD. "Stuff" means things like git checkout -- <file>
, git reset HEAD^
, and other commands I cannot remember as I'm new to git and I'm trying to research best practices.
At any rate, after I finally "undid" my commit and did a git pull
, I got 66 commits worth of changes, including my patch, and everything looked great. But then git status
showed that two files were untracked. I did a gitk <untracked_file1>
and I saw that about 20 commits back, the file was moved to another directory. The file now exists in the new location, but instead of deleting the old file, it shows up as untracked.
I tried doing a hard reset by following these instructions, but the files remain untracked. I can do a git clean -f
to clear them out, but I'm wondering why the files aren't automatically removed.
git pull doesn't delete uncommitted changes, it doesn't deal with your working directory, any changes or new files will not be touched unless it committed.
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 .
Ahmed Kamal's answer did not change a thing in my case for a similar problem. I used git clean -f <folder_name>
which successfully removed the folder from the files I was tracking.
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