This is so problematic, I have just git pull something and then it says there is local change.... I changed nothing... I tried reset hard but it is not useful... Anyone help?
MacBook-Pro$ git reset --hard
HEAD is now at b89fcff the latest code in AWS to identify all difference and keep track
MacBook-Pro$ git checkout dev1.1
error: Your local changes to the following files would be overwritten by checkout:
OUTPUT_RESULTS_DIR/equity.csv
Please commit your changes or stash them before you switch branches.
Aborting
Performing git reset --hard will only affect those files, Git knows about; those that are currently tracked by Git.
When you take the output of git status as a reference, what git reset --hard affects are only those files for which Git has detected modifications which are either staged or not staged. Files listed in the untracked section, and as such are not “known by Git”, are not affected.
So in your case, you have an untracked file OUTPUT_RESULTS_DIR/equity.csv. Doing git reset --hard will not affect it, so it stays where it is. However, the branch dev1.1 you attempt to check out, apparently contains that file. So here, Git will protect you from accidentally losing the content of your local file by preventing you from checking out.
At this point, you could rename the file so that you still have it around but it won’t cause a conflict when checking out the other branch. You could also use git checkout dev1.1 --force to force Git to check out the branch, ignoring any conflicts. However note, that this action cannot be undone, so be careful with it.
If you're certain there are no changes you care about, then there is no reason to try committing or stashing (or even resetting.) You should be able to force the checkout as follows:
git checkout --force dev1.1
The --force option causes Git to discard any local changes rather than failing on them. Just be sure this is really what you want to do.
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