Reputation: 71
How to remove the items under "Changes not staged for commit:". I found many other tickets in this regards, but none actually worked with me.
What happened ?
I checked out the development branch. But after i edited some local files, these files got stuck in the Unstaged list. Can't stash
, clean
, rm
or even reset --hard
them at all. The problem happened when i was trying to remove my local changes by checking out origin/mybranch then trying to reset from there.
Some how i have now an outdated branch. Every time i do :
git fetch origin
git reset --hard origin/mybranch
the unstaged changes STILL there.
modified : *.xlsx
Ho can i force removal of these local changes. It seems the only solution is to clone a clean revision again, but i'm trying to fix it first.
Upvotes: 0
Views: 804
Reputation: 71
So this problem happened only with .xlsx files because every time it's opened by Excel it create a hidden file $.xlsx. Apparently the same issue with other office document files. If i added the changes through :
git add .
It will blindly add even the hidden file $*.xlsx . So after i closed the file, automatically it was removed from the system but not from git because it was added already, git still sees it and can't ignore it or even remove because it was untracked.
What worked for me that i opened the excel file, add, then commit without issues. After that i can remove as any other file.
Upvotes: 0
Reputation: 254
If these files you've changed are within a tracked directory and you are looking to permanently exclude them from the project, you would need to add them to your repository's .gitignore file.
Upvotes: 0
Reputation: 21
Try:
git checkout .
The '.' is used to indicate that you want to replace ALL the files with the version present in origin.
Upvotes: 2
Reputation: 1411
The changes not staged can be "removed" using the following command:
git checkout -- <filename>
Or, if you want to remove all the changes, you can use .
git checkout -- .
This should be sufficient to remove items under "Changes not staged for commit".
Upvotes: 0