Git creates a new branch from a remote master server

Source: Internet
Author: User

existing version; H20, H28,h26,i8

H28,h26,i8 is created from the H20 below.

Requirements: Create a new branch from below H28 continue development.

Ideas:

All the code is placed in the H20 warehouse, first download the H20 full repository, that is, the. git folder content, which is essentially a zip file.

Then remove a branch from the repository (such as H28), which is all the code that synchronizes to a branch (essentially reading a portion of a file from a zip).

Note: At this point the local is the H28 branch, we make the changes are above the H28, but the actual need is that we are on this basis to create a new branch.

Specific implementation code

1. Replicating Server Code

git clone ssh://[email protected]/git/h20/pizza.git D96

2. Switch to a branch

git checkout h28

Note: I was just beginning to wonder if I had not created a branch locally, so I could switch branches. have been the first to start from scratch to create a git repository, the warehouse is empty, where the branch, and now is downloaded from the server to complete the warehouse, the warehouse of course there are branches, otherwise the code how to manage.

3. Create a new branch on top of some basics

Git checkout–b D96

Create a branch and switch to the new branch at the same time.

4. Sync to the server, associate the new branch with the parent branch and make it easy for colleagues to enter together (he is also the same, download the warehouse, just switch branches, not switch h28, and D96, and do not need to create a new branch)

Git push Origin D96

View Main Branch Associations

git branch–a//view Remote Branch

* D96//Local Development Branch

H28//Local Branch

Master//Local Master branch equivalent to H20

Remotes/origin/d92

REMOTES/ORIGIN/D96//New branch above the remote server

Remotes/origin/head–> origin/master//Current branch status on remote server

Git creates a new branch from a remote master server

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.