Monday, September 12, 2011

Creating a branch from a previous commit.

How many times have we found ourselves not tagging a particular build and passing it on the some client. When defects are found the question that is asked everytime is "Can we fix it for that build please?" or "We cant take the risk with the current code, need to fix it for that build only". Well subversion has an update to revision and revert options what about git?


I have to fix a defect in a commit made 2 weeks ago. I have on me a SHA, what can I do? I decided to checkout that SHA so I did

bmansharamani@BINDIYA-PC /d/Ent6 (develop)
$ git checkout ddb0a72586c6b64f3d433dfe823f0156e7c5463a
Note: moving to 'ddb0a72586c6b64f3d433dfe823f0156e7c5463a' which isn't a local branch
If you want to create a new branch from this checkout, you may do so
(now or later) by using -b with the checkout command again. Example:
  git checkout -b
HEAD is now at ddb0a72... testing fix of repo size issue


bmansharamani@BINDIYA-PC /d/Ent6 ((ddb0a72...))
$ git checkout -b TestBranch
Switched to a new branch 'TestBranch'


Fixed the issue and whoa! the problem solved.