Thursday, September 13, 2018

Regress to an old commit in GIT

# make a branch named B started on the commit B
git checkout -b B <sha1 id of the commit B> 
# it creates a branch which starts at a commit
# right before B and has exact copy of commit as B,
# but with a different sha1 id.
git rebase --no-ff HEAD~1

# now we do simple merge
git checkout master
git merge B

What I needed to do was to go back in time in my Repository. So there was a bunch of changes that were made to my code base but I realize that two changes were not going to work. The decision was made to go back to the original code base before it was modified. The best way to do that was to progress in our Repository to the sha1 that had the correct, older code. This process mentioned here simply checks out an old commit and turns it into a branch. Then you merge that branch with master and, bingo! All is wonderful!

https://stackoverflow.com/questions/11905428/merge-old-git-commit-with-head-at-master/11913700

No comments:

Post a Comment

How to use WinSSHFS on Windows 10

The documentation for how one uses WinSSHFS on Windows 10 on the Internet, in my opinion, sucks. That said (and yes I feel better now),...