Git Common commands

Source: Internet
Author: User

Http://www.xbc.me/git-commands/

Get git Repository

Initialize a version Repository

 

Git init

 

Clone remote version Library

 

Git clone git@xbc.me: WordPress. Git

 

Add the remote repository origin. The syntax is GIT remote add [shortname] [url].

 

Git remote add origin git@xbc.me: WordPress. Git

 

View remote Repository

 

Git remote-V

 

Submit your modifications

Add the modified file to the temporary storage area

 

Git add.

 

If you automatically track files, including those that have been manually deleted and are in the deleted status

 

Git add-u

 

Submit your modifications

 

Git commit-M & quot; Your Comment & quot;

 

Push your updates to the remote server. Syntax: git push [remote name] [local branch]: [remote branch]

 

Git push origin master

 

View File status

 

Git status

 

Tracking new files

 

Git add readme.txt

 

Remove files from the current trail list and delete all files

 

Git RM readme.txt

 

Only deleted in the temporary storage area. The files are retained in the current directory and will not be tracked.

 

Git Rm-cached readme.txt

 

Rename a file

 

Git MV reademe.txt readme

 

View submitted history

 

Git log

 

Modify the comments submitted last time by using the -- Amend Parameter

 

Git commit -- Amend

 

If you forget to submit some modifications, only one of the following three commands will be submitted.

 

Git commit-M & quot; add readme.txt & quot;

 

 

Git add readme_forgotten

 

 

Git commit-amend

 

Suppose you have used git Add. To add the modified files A and B to the temporary storage Zone

Now you only want to submit file a and file B.

 

Git reset head B

 

Cancel File Modification

 

Git checkout -- readme.txt

 

Basic branch management

Create a branch

 

Git branch iss53

 

Switch the working directory to iss53

 

Git chekcout iss53

 

Combine the preceding commands to create the iss53 branch and switch to iss53.

 

Git chekcout-B iss53

 

Merge iss53 branches. The current working directory is master.

 

Git merge iss53

 

After merging, no conflict occurs. Delete the iss53 branch.

 

Git branch-D iss53

 

Pull the data from a remote repository. The syntax is GIT fetch [Remote-name].

 

Git fetch

 

Fetch pulls the latest remote warehouse data but does not automatically go to the current directory.

 

Git pull

 

View remote Repository Information

 

Git remote show origin

 

Create a local Dev branch to track the develop branch of the remote Repository

 

Git checkout-B Dev origin/develop

 

References

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.