Reputation: 18237
I want to revert to an old version and commit it as a new version:
So I do:
git checkout 1778b26 .
However, if there was a renamed file involved between the latest version and the version I am checking out, both file names would exist. git clean -fdx
does not fix this.
How do I make sure that , when I check out that old version as new, the files and directories are exactly as the old version?
Upvotes: 2
Views: 135
Reputation: 1323203
You can:
git reset --hard oldSHA1
oldSHA1
.yourCurrentBranch
previous HEAD
(marked tmp
):git reset --soft tmp
From there, you can add and commit: that will create a new commit which will have the exact same content as the old SHA1.
Upvotes: 2
Reputation: 118292
Use
git diff 1778b26..HEAD | git apply -R --index
This generates a diff between that other commit and your current HEAD
, then reverses the diff, applies it to HEAD
, and then records the changes in the index.
This should work as long as you do not have any binary files in your repository.
Upvotes: 1