How do I "turn" a specific commit into a branch?

Asked

Viewed 2,629 times

4

I’d like to take one commit previous specific and turn it into a brancho.

Is there any way to do that in the Git?

2 answers

8

Just pass the commit ID when creating the branch:

git checkout -b BRANCH_NAME COMMIT_ID

Example

git checkout -b teste 5d6b8da2f0e32a100087eecb73fc2dd47579748f

With this, a new "test" branch will be created based on the commit: 5d6b8da2f0e32a100087eecb73fc2dd47579748f

3

To view commit history, type:

git log

After that, just grab the commit ID you want:

git commit -b nomebranch 7e85bcb18b1fcf58738f3ec6a2e04171975ef442

Or:

git checkout 7e85bcb18b1fcf58738f3ec6a2e04171975ef442
git checkout -b nomebranch

Browser other questions tagged

You are not signed in. Login or sign up in order to post.