Reputation: 3423
This is frustrating and I simply can't find the right answer on how to handle this. I am after a rebase [but this is just one of many scenarios where this problem occurs] and I have a ton of files "changed but not updated" that have no difference but for the newline characters.
git diff -b
nothing returned.
Now I just want to remove the changes and leave files as they are in the repo. I've found plenty of "solutions":
1 Stashing changes
a) with --keep-index [this was actually from SO]
$ git stash save --keep-index
Saved working directory and index state WIP on COM-23: 4a8abc1 COM-23 changed pa
ckage name
HEAD is now at 4a8abc1 COM-23 changed package name
$ git stash drop
Dropped refs/stash@{0} (7d822e3c6bdc310f4a4be90ed937dd0ea97df627)
$ git status
[tons of files marked as changed but not updated]
b) without --keep-index
exactly the same as with 'a'
2 git reset
a) just a reset
git reset --hard HEAD
same as above
b) with add
git add -A
git reset --hard HEAD
same as above
3 checkout
git checkout
same as above, status returns a lot of unstaged files.
I am quite certain I am doing something wrong or just misunderstanding the problem, but all I want to do is to get rid of the unstaged changes! How can I do that?
Thanks, Krystian
Upvotes: 6
Views: 7623
Reputation: 463
Use git stash when you want to record the current state of the working directory and the index, but want to go back to a clean working directory. The command saves your local modifications away and reverts the working directory to match the HEAD commit.
Do like this.
git stash save --keep-index
and if you want to remove this changes completely then drop the stash
git stash drop
Upvotes: 0
Reputation: 179219
Check out git config [--global] core.autocrlf
. It's best to have it set to false
. You may still need a git reset --hard
after changing that value, because you have to sync your editor newlines settings with those of Git.
Upvotes: 10