Easily submit code with GIT commands

Source: Internet
Author: User

GitHub offers a good graphical client on both Windows and Macs, with UI style savings and features that are easy to use. But we still need to be familiar with GIT commands to maintain code, such as Linux.

Five steps to borrow the Git commit code summarized by @sunshyran:

    1. To view the modified state of the Code
    2. See what's changed in the code
    3. Staging code that needs to be submitted
    4. Submit a file that has been staged
    5. Sync to Server

STEP1, viewing the modified state of the Code

Open git shell (environment: Take windows as an example, install GitHub client and configure account information), default is the workspace path in Git, The LS command can view all directories under workspace (recommended: The directory under workspace should be in project), and the CD command enters the target project.

git status

The red font is a status indicator for changes in the project:

Modified represents a file that has been modified compared to the previous version

The new file represents the newly added

Deleted the file is deleted, the file will be deleted from repository after successful submission

untracked file means that files are not processed

STEP2, see what's changed in the code

git diff <filename>

Here you see the changes in the. gitignore file.

To view historical changes, you need to use the node Hashcode (Hashcode can be obtained from the commit record on GitHub):

git diff 

STEP3, staging the code to be submitted

Add a file that needs to be uploaded:

git add <filename>
To delete an unwanted file:

git rm <filename>
Add all the files you need to upload:

git add--all
STEP4, submitting files that have been staged

Git commit-m <comment>

If a file is found to be missing or commented incorrectly, use amend to fix it:

git commit--amend-m <meg>

Note: Using the commit command simply commits the modifications to the local repository

STEP5, synchronizing to the server

Use the push command image to push the changes to GitHub's code server so that you can access the codes anywhere.

Git push-u Origin Master

Congratulations, you have successfully synced the code to the GIT server.

The document is designed to help git beginners easily use git command to commit code to a git server, such as creating libraries and conflict processing, branching and other advanced knowledge This article is not too much elaboration.


Easily submit code with GIT commands

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.