Yimin Rong
Yimin Rong

Reputation: 2027

How to branch from a branch

I have been asked to create branch 1.2.1 from branch 1.2, and work on branch 1.2.1 locally. I think branch 1.2 is on the main server, but then I also read that git automatically copies the complete repository locally, so I don't know where branch 1.2 is located.

I have reviewed several questions which I think attempt to answer this, but they all give different answers, and all have replies saying it didn't work, or maybe try this instead. I need certainty on this, because experimenting just leads to me losing my work or corrupting the repository.

Upvotes: 0

Views: 134

Answers (1)

Matt Grande
Matt Grande

Reputation: 12157

  1. Make sure you have all the code from the remote server:

    git fetch origin

  2. Checkout the code for branch 1.2

    git checkout 1.2

  3. Create your new branch.

    git checkout -b 1.2.1

It should be that easy.

Upvotes: 2

Related Questions