Common Git commands

Source: Internet
Author: User
Tags git commands

Common Git commands

For the Git basic tutorial, refer to the next article: Git basic tutorial.

 

Category Specific commands
Local submission Initialize the Repository: git init
Add the file to the repository: git add filename
Submit the file to the repository: git commit-m "message" (temporary storage area)
Delete the file from the Repository: git rm filemame + commit
View the status of the staging area: git status
Undo the local modification: git checkout -- filename
Undo the modification of the temporary storage area: git reset HEAD filename
View the differences between the workspace and the temporary storage zone: git diff
View the differences between the staging area and the Repository: git diff -- cached
View the differences between the workspace and repository: git diff HEAD
View history: git log (-- pretty = oneline optional parameter)
Roll back the local file to the specified version: git reset -- hard version_number
Roll back the local file to the previous version: git reset -- hard HEAD ^
View Command records: git reflog
Branch Operations Create branch: git branch dev
Create and switch to the branch: git checkout-B dev
Switch branch: git checkout master
Delete branch: git branch-d dev
Merge with current branch: git merge dev
View branch: git branch
Remote warehouse operations Create an SSH Key: ssh-keygen-t rsa-C "youremail@example.com"
Clone from remote database: git clone git @ link/file. git (a local repository is automatically created after cloning)
View the associated remote Repository: git remote-v (add v to display the address of the remote repository)
Pull and merge from remote Repository: git pull origin dev
Obtain and merge from a remote Repository: git fecth origin dev + git merge origin/branch
Push local repository content to the associated remote: git push origin master (master is the current Branch)
Associate a remote repository with a local repository: git remote add origin git @ link/file. git (origin is not a fixed value)
Set the association between local branches and remote branches: git branch -- set-upstream-to origin/dev
Stash operation Storage "work site": git stash
View the stash region: git stash list
Restore stash content: git stash apply stash_number
Delete stash content: git stash drop stash_number

 

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.