Github creates a new branch

Source: Internet
Author: User
Tags git clone
First, clone Repository

Clone repository on Github, as follows:

git clone git@github.com:fbing/design-patterns.git
Ii. Branch of Management 1. View Branches 1. View Local branches

Use the git Branch command, as follows:

$ git Branch
* Master

* Identifies the branch you are currently in. 2. View Remote Branch

The command is as follows:

Git branch-r
3. View all Branches

The command is as follows:

Git branch-a
2. Create a new branch locally

The command is as follows:

GIT branch [branch name]

For example:

Git branch Gh-dev
3. Switch to a new branch

The command is as follows:

git checkout [branch name]

For example:

Ricky@desktop-1qpastr mingw64/f/git_studio/design-patterns (Master)
$ Git Checkout gh-dev
switched to branch ' Gh-dev '

ricky@desktop-1qpastr mingw64/f/git_studio/design-patterns (Gh-dev)
4. Create + switch branches

To switch to the branch while creating the branch, the command is as follows:

git checkout-b [branch name]

The effect of git checkout-b [branch name] is equivalent to the following two steps:

GIT branch [branch name]
git checkout [branch name]
5. Push the new branch to GitHub

The command is as follows:

Git push origin [branch name]

For example:

Git push Origin Gh-dev
6. Delete local branch

The command is as follows:

git branch-d [branch name]

For example:

Git branch-d gh-dev
7. Delete GitHub Remote Branch

The command is as follows:

Git push origin: [branch name]

The colon before the branch name represents the deletion.
For example:

git push Origin:gh-dev

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.