Git Common Command Collation

Source: Internet
Author: User

Git Common Command Collation

Get git repository

Initializing a repository of repositories

Git init

Clone Remote Repository

git clone [email protected]:wordpress.git

Add remote repository origin, syntax for git remote add [shortname] [url]

git remote add origin [email protected]:wordpress.git

View Remote repositories

Git remote-v

Submit your changes

Add the currently modified file to staging area

git Add.

If you automatically track files, including files that you have manually deleted, the status is deleted

Git add-u

Submit your changes

Git commit–m "Your comment"

Push your updates to a remote server with the syntax git push [remote name] [local branch]:[remote branch]

Git push Origin Master

View file status

git status

Track new files

git add readme.txt

Remove files from the current trace list and remove them completely

git rm readme.txt

Delete only in staging area, keep files in current directory, no longer track

Git rm–cached readme.txt

Renaming files

git mv Reademe.txt Readme

View the history of a submission

git log

Modify the last commit comment, using the –amend parameter

git commit--amend

Forgetting to commit some changes, the following three commands will only get one commit.

Git commit–m "Add readme.txt"

git add Readme_forgotten

Git commit–amend

Let's say you've already used git Add., add the modified files A, B to staging area

Now you just want to submit a file, do not want to submit B file, should

git reset HEAD b

To cancel the modification of a file

Git checkout–-readme.txt

Basic Branch Management

Create a branch

Git branch iss53

Switch working directory to iss53

Git chekcout iss53

Combine the above commands together to create a ISS53 branch and switch to ISS53

Git chekcout–b iss53

Merge iss53 branches, current working directory is master

git merge iss53

After the merge is complete, there is no conflict, delete the ISS53 branch

Git branch–d iss53

Pull data from remote repository, syntax for git fetch [remote-name]

git fetch

Fetch pulls up the latest remote repository data, but does not automatically merge to the current directory

Git pull

To view information about a remote warehouse

git remote show origin

Establish a local dev branch to track the develop branch of the remote repository

git checkout–b Dev origin/develop

Resources

Use of remote warehouses

What is a branch

Basic branching and merging

Management of Branches

Branching workflow

Remote Branch

Yan He

Git Common Command Collation

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.