Search code examples
c#asp.net-mvcgitvisual-studio-2015rollback

Checkout/Rollback specific commit ID GIT (Possibly Duplicated)


I have three commits, but i want to checkout the last commit and start working from there. But also keeping the other commits too i.e. when i commit again it will be a new commit and will not mess up my other commits :)

Its also possibly a duplicated question, but since its a crucial scenario I have asked my own question.

If there is any GUI solution please prefer that solution because i am new at GIT :)

Best answer someone gave me is that : git checkout -b old-state 0d1d7fc32 but i am not be able to do this :S

Also if i revert two times to checkout the 3rd commit, it will delete the first two reverted commits?

Issue


Solution

  • I don't know which GUI tool you are using. I always use CLI. But the theory is the same.

    1. create a new branch "branchA" that refers the newest commit 98ea8a1d

    2. hard reset current branch "feature/RPG……" to commit f6f69dc1

    So,the last two commits are protected by branchA. And current branch is rollbacked to f6f69dc1. And you can do things from f6f69dc1.