Getting started with GIT: How to Use command lines to synchronize code

Source: Internet
Author: User
Tags git commands

GIT is currently a popular open-source code collaboration tool, but it is difficult for beginners to learn how to upload code and download synchronization. There are roughly two solutions. One is to use the git gui that provides the interface. For details about how to operate it, see the following link.

Http://hi.baidu.com/mvp_xuan/item/789262104e758f3bb93180d2

The second method is to use the GIT Batch command line mode. However, how to identify the local branch or the server branch is a bit messy.

To clarify your ideas, click the version library in the git gui-> View the history of all branches in the diagram:


Is the Historical List. The local branch name is "master", and the server branch name is "origin" instead of "master ). Of course, this local name can be changed. Now we know the corresponding relationship, who should push it to or who will pull it.


To push the local code to the server, the local master branch that has been committed is actually pushed to the origin branch of the server. Start GIT Batch in the IDE project and use the git push origin command. The complete command here should be git push master origin, and the local master can be omitted.

To synchronize the server-side code to the local, the essence is to take the origin branch of the server (fetch) and give it to the local code in pull. Therefore, the command first uses git fetch to retrieve the latest code on the server. The complete code is git fetch origin, which is the default and omitted. Then, git pull origin master is synchronized to the local master version.

Another example of the popular GIT commands on the internet is as follows:


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.