Reputation: 1973
I made a mistake moving between branches.
git checkout -f myBranch
This is my mistake and lost my data. is possible to revert or reset or rollback like undo to restore my files?
Thanks!!
Upvotes: 0
Views: 85
Reputation: 14439
If you check out an other branch using checkout -f
, your uncommited changes are lost (except for untracked files). As said here :
-f --force
When switching branches, proceed even if the index or the working tree differs from HEAD. This is used to throw away local changes.
If your changes were local and never even part of a commit, there is no way to restore them, since git does not know about them.
Any operation using -f
or --force
should be used with caution, since yout can potentially loose your local changes with no way to recover them. Make sure you have a clean working tree (e.g. commited local changes) before performing such operations.
I assume you lost your local changes here, or do you speak of changes that already were commited at any point?
Upvotes: 1