Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in DevOps and Agile by (19.4k 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 (27.5k 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>

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...