Git usage: how to configure Branch

Source: Internet
Author: User

Http://blog.rexzhao.com/2011/11/22/git-branch.html

Git is a distributed system, but git usually sets up a central server when working in a group. Everyone pushes/pull to this server.Code.

Sometimes you need to leave the main line (master) for some testing or debugging work, or want to divide the code into the development version, stable version, etc., at this time you need to do branch.

In the structure of the central server, all remote terminals are the central server, so the configuration method is (taking the dev branch as an example ):

    1. Login Server
    2. Execute git branch Dev to create the dev Branch
    3. Execute git pull locally for updates, and then git checkout Dev can switch to the dev branch.

In addition,When git pushes the origin, it will push all the branches of the origin.(If there is only one remote end, remote can be left empty, so the command is GIT push in general ),If you only want to push a branch of your own, use git push-F-v-N origin Dev.

 

Google Code: Why 'Everything up-to-date' when pushing (GIT)

Get the project on Google Code for the first time. After registration, try to add a new file to test whether git works well. The result is "Every up-to-date" displayed during the push operation. when checking the file, it is found that none of the files are actually updated. Because I am not familiar with git, I Have To Googling.

After searching, find the cause as follows:

Why does git refuse to push, saying "everything up to date "?

Git push with no additional arguments only pushes branches that exist in the remote already. if the remote repository is empty, nothing will be pushed. in this case, explicitly specify a branch to push, e.g. git push master.

That is to say, the GIT server repository is completely empty at the beginning and does not contain any branch. Therefore, you need to specify one when you start pushing.

After running git remote-V, you can see that your remote end name is origin:

$ Git remote-V
Origin https://code.google.com/p/micolog2 (FETCH)
Origin https://code.google.com/p/micolog2 (push)

After running git branch, you can see that the current branch you are using is the master:

$ Git Branch
* Master

Therefore, after the local commit, run

Git push origin master

You can.

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.