Git Common Commands Summary

Source: Internet
Author: User

1. Configure User name and password
$ git config--global user.name "x"
$ git config--global user.email "x"

View User Name
$ git config user.name

2, clone a git repository

Git can communicate through a lot of protocols, with three of the most important protocols, Ssh,http,git (a full-time protocol for GIT services)

Anonymous access: Via git://or HTTP.
Regardless of the protocol used to clone the Git store, the format is: ' Git clone uri ', URI format:
"GIT://(hostname)/(path). Git"

$ git clone git://github.com/xx/munger.git
$ git clone http://github.com/xx/munger.git


3, switch branches
git checkout Master

4, view Log
git log--pretty=oneline

5. deleting files
git rm file name

6, Version fallback
git reset--hard head^
The previous version was head^,
The last version of this is head^^.

7, the deleted file returns the latest
Git checkout--readme.txt
Command git checkout--readme.txt means to undo all changes to the Readme.txt file in the workspace, here are two things

8. View Historical version
Git reflog

10,push to remote libraries
First time push to master with Git push-u origin master
The second push uses git to push Origin master

11. Create Dev Branch and switch to Dev branch
git branch-d branch Name
View branches: Git branch
Create a branch: Git branch <name>
Switch branches: git checkout <name>
Create + switch branches: git checkout-b <name>
Merge a branch to the current branch: git merge <name>
Delete branch: Git branch-d <name>


git log--graph command to see the branch merge diagram.

git log--graph--pretty=oneline--abbrev-commit

12, merging branches
Git merge--no-off-m "merge" Dev

Git Common Commands Summary

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.