My problem is that I approached git rebase -i too lightly and after adding pick and f to subsequent commits, it turned out that Git ate most of my code, and I worked on a dozen files for a week.
is there any way to revert the changes? I knew I wasn't doing it cleverly by uploading to bitbucket with force, but I wanted to do a merge with devel.
CodePudding user response:
git reflog
in your local working directory will give you the complete list of past states of the repository.
Find your previous git hash in that list, and then do git reset HASH
to restore the working directory
CodePudding user response:
On your local GIT repo you can use what git calls the reflog. The reflog keeps track of every changes you make to your git repo.
For instance, in your case, after a rebase, a new entry appears in the reflog. To revert the changes made by mistake you can checkout to specific point in the reflog, retrieve your work or restart from there.
The associated command is git reflog
. Then the usual git commands do the job git checkout -b MY_TEMP_BRANCH XXX
where XXX
denotes the SHA`of the reflog entry you want to go to.