GIT basic operations: uploading Code

Source: Internet
Author: User

Using Git to submit native code to a remote server is generally divided into the following 5 steps:

First, view the status of the current file

Use the git status command to see which files have been modified, typically in the following states:

1. untracked: Not tracked, this file is in the folder, but is not added to the GIT library and does not participate in version control. The git add state changes to staged.

2, Modified: The file has been modified, is only modified, and no other operation.

3, deleted: The file has been deleted, deleted locally, the server has not been deleted.

Examples are as follows:

Open the Git bash client and enter the git status command:

Then enter, you can see the current workspace changes, where the Red font section represents the modified file:

Second, add the modified file to the local git buffer

Use git Add. or git add xxx command to add the modified file to the local git cache.

1, if you git status to view the current status of the discovery is the file you have modified, you have to commit, then you can directly use git Add. You can add all of your content to your local git cache.

Note: git Add. (There is a point later) to add all the files in the directory to the local git cache. As shown in the following:

2, if you git status to view the current status of some files you do not want to commit, then use git add xxx (xxx means you want to add the file name) command can submit some files to the local git buffer. As shown in the following:

Third, submit the code to the local warehouse

Use the command: Git commit-m "Add your comments, usually some change information" push the file in the local git cache to the local git library. As shown in the following:

Iv. Get updates for a branch of a remote host, merging with the specified branch locally.

Use the GIT pull < remote host name > < remote Branch name > command to get updates for a branch of a remote host. For example, the remote host is the Origin remote main branch named Master and we can write Git pull Origin master. As shown in the following:

Push the code of the local git library to a branch of the remote host.

Use the GIT push < remote host name > < remote Branch name > command to push the code currently submitted to the local Git repository to a remote point on the remote host. As shown in the following:

Attention:

1, in the fourth to obtain remote branch updates and merge with the local git library code, there may be conflicts, you need to resolve the conflict before you push to the remote branch.

2, in the fifth step push to the remote branch, it is possible to enter a git username and password, then follow the prompts to enter the user name and password.

GIT basic operations: uploading Code

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.