Common git commands, git

Source: Internet
Author: User
Tags git commands

Common git commands, git

Git status
Git add puts the workspace in the hold Zone
Git commit puts the hold zone into the version Zone
Git add submits all modified files to the hold Zone
Git commit-m "Remarks written when submitting" no reference
Git commit-a-m "Write remarks upon submission" directly submit the workspace to the version Area
Git log to view submitted commands
Git clone + address clone

Enter the project
Git config -- global user. name "name"
Git config -- global user. email "email"
Git config -- view global user. email
Git config -- list View All
Git diff workspace and hold zone comparison
Git diff -- Comparison between cached hold zone and version Zone
You can also use git diff -- staged.

 

Git add. All modified files are submitted to the temporary storage area.
Git commit-m "submit remarks": Submit the remarks to the version area. If no comments are displayed, write the remarks directly.
Git commit-a-m "submit remarks" is submitted from local to the temporary storage area in the commit version area. (You cannot skip the temporary storage area and submit it directly to the version area)

File comparison
Comparison between git diff workspace and temporary storage Zone
Git diff -- cached (git diff -- staged) Comparison between the staging and version zones
Git diff master workspace and version zone comparison

Undo
Git reset HEAD "file name" restored from the temporary storage area to the Workspace
Git checkout "file name" restores the version workspace to the version region status
Git commit -- amend to recall the last commit, submit it together with this commit, and use a version number

Delete
The git rm file name deletes the files in the temporary storage area.
The git rm-f file name workspace does not delete files in the temporary storage zone. (Delete the workspace and the temporary storage area together)
The git rm -- cached file name workspace does not delete files in the temporary storage zone. (Delete only the temporary storage area, and do not delete the workspace)

Restore
Git checkout version id file to be restored
Git reset -- hard version id is directly restored to the previous version
Git reset -- hard HEAD ^
Git reset -- hard HEAD ~ Number back to previous versions
Git reflog to view recent operations
Git reset -- hard version id back to previous version


Synchronize to remote Repository
Git remote view remote repository name
Git remote-v: view the address of the remote Repository
Git push origin (repository name) master (branch name) synchronized to gitgub remote Repository

Update local (resolve multi-user conflicts)
Git fetch pulls files from a remote Repository
Git diff master origin/master to view conflicting content
Git merge origin/master local and remote repository merge
Git pull and merge
Open-source project collaboration

Branch
Git branch view branch
Git branch name create branch
Git checkout branch name switch Branch
Git checkout-B branch name: the branch that creates a new branch and switches to the new key.
Git merge branch name merge Branch
Git branch -- merged: View merged branches under the current branch
Git branch -- no-merged check that no merged branches exist under the current branch
Git branch-d branch name Delete branch
(List conflicting files, manually resolve the conflicts, and then submit the files)

Create this branch on github
Git push origin (repository name) master (branch name) synchronized to gitgub remote Repository
Tag on github
Git tag Name create tag
Add the git push origin tag name to the remote Repository

Ls view directory structure
Create a folder using mkdir

Related Article

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.