Git remote branch creation and management

Source: Internet
Author: User
1. The remote branch is generated when the local branch is pushed to the server. For example, the master node is the most typical remote Branch (default ).
1 $: git push origin master
Apart from the master, we can also create branches and push them to the server. For example:
1 $: git push origin develop
2 Counting objects: 27, done.
3 Delta compression using up to 2 threads.
4 Compressing objects: 100% (15/15),
done.
5 Writing objects: 100% (15/15), 7.30 KiB,
done.
6 Total 15 (delta 10), reused 0 (delta 0)
7 To git@search.ued.taobao.net:projects/search.git
8    1b95a57..779dbe1  develop -> develop
2. The remote branch must be differentiated from the local branch. Therefore, when pulling a specific branch from the server, you must specify the local branch name.
1 $: git checkout --track origin/develop
Note that this command has the -- track parameter, so git1.6.4 or above is required! In this way, git automatically switches to the develop branch. 3. synchronize local remote branches:
1 $: git fetch origin
4. Submit the branch data to the remote server:
1 $: git push origin <local_branch_name>:<remote_branch_name>
For example:

1 $: git push origin develop:develop
Of course, you can directly

1 $: git push
5. Delete the remote branch develop:
1 $: git push origin :develop

At the first creation, there were no branches on the server (using git init -- bare). Then, a branch must be pushed to the server after being created locally.

That is, the first push must write git push origin master: master as follows:

Git checkout master // get the head of the master version.
Git checkout tag_name // get the version of tag_name on the current Branch
Git checkout master file_name // discard the current modification to the file file_name

Git checkout branch_name tag_name // get the version of tag_name of the specified branch_name Branch

Git checkout commit_id file_name // get the version of file_name in commit_id.

Commit_id is the Sha value when git commit is used.

 

List the patches corresponding to a commit ID (xxxxxxxxxxxxxxxx:

$ Git log-1-P xxxxxxxxxxxxxxxx
$ Git format-patch-1 xxxxxxxxxxxxxxxx <=-1 cannot be omitted
-- Stdout // print to standard output
$ Git show xxxxxxxxxxxxxxxx
$ Git diff-tree-P xxxxxxxxxxxxxxxx

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.