-4

I made 6 commits on the master(main) branch, and I added a new branch which starts from the 2nd commit of master branch. But that was yesterday's work. Today, I want to make another brand new branch which starts from the 3rd commit of the master branch. Please tell me how to do that.

I was making commits as usual on master branch....and in that way I made a total of 6 commits in that branch. And, in advance, I already created a new branch from the 2nd commit of master branch, right? In that branch, I made 4 commits. So I wish to create another branch which starts from the 3rd commit of the master branch. But in order to do so, I was unable to get back to the previous commits, because, I Don't know how to do that! Please let me know, how to achieve what I want, by telling me the necessary git commands/important steps.

3

1 Answer 1

1

You can view the commits that you have via

git log

You will see a list of commits and each of those commits has a hash (alphanumeric character string). So, you will need to check out that hash via

git checkout <thehash>

create the branch

git branch <branchname>

and check out the new branch:

git checkout <branchname>

You can push such a branch to the origin (remote) via

git push -u origin <branchname>
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.