cibercitizen1
cibercitizen1

Reputation: 21476

Git: how to return to a past commit to start a branch keeping all commits?

Let's suppose we have this history of commmits:

c0 <- c1 <- c2 <- c3 <- c4 (master)

how can I get this?

c0 <- c1 <- c2 <- c3 <- c4 (master)
            ^
            |- c21 <- c22 (test)

This is, keep al the work done, but starting a new branch from a past point.

Thanks

Upvotes: 1

Views: 114

Answers (2)

xdazz
xdazz

Reputation: 160833

You could do it with one line:

git checkout -b test c2

Or if you just want to create the new branch and without checkout:

git branch test c2

Upvotes: 4

cexbrayat
cexbrayat

Reputation: 18402

You can do a simple checkout :

git checkout c2

And then start your branch as usual :

git checkout -b test

Upvotes: 5

Related Questions