0 votes
1 view
in Devops and Agile by (20k points)
edited by

If I have n commits, how can I branch from the n-3 commit?

I can see the hash of every commit.

1 Answer

+1 vote
by (28.4k points)

Use the following command to create the branch using hash:

$ git branch branchname <sha1-of-commit>

For example,

$ git branch branchname HEAD~3

In order to checkout the branch while creating it use the following command: 

$ git checkout -b branchname <sha1-of-commit or HEAD~3>

Welcome to Intellipaat Community. Get your technical queries answered by top developers !