List of common Git commands

Source: Internet
Author: User
Tags git commands

I use Git every day, but I can't remember many commands.

In general, the daily use of just remember 6 commands, you can. But skilled use, I am afraid to remember 60~100 a command.

Here's a list of common Git commands I've compiled. Several special nouns are translated as follows.

    • Workspace: Work Area
    • Index/stage: Staging Area
    • Repository: Warehouse area (or local warehouse)
    • Remote: Repository
First, create a new code base
# Create a new Git codebase in the current directory $ git init# create a new directory, initialize it to git code base $ git init [Project-name]# Download a project and its entire code history $ git clone [ur L]
Second, the configuration

Git's settings file is .gitconfig , it can be in the user's home directory (global configuration), or under the project directory (project configuration).

-----e [--global]# user information when setting up the commit code $ git config [--global] [name] " $ git config [--global"[email address]"
Third, add/delete files
--Cached [file]# renamed the file and put this name in staging area $ git mv [file-original] [file-renamed]
Iv. Code Submission
------amend---amend ...   
V. Branches
# List all local branches $ git branch# list all remote branches $ git branch-r# List all local branches and remote branches $ git branch-a# creates a new branch, but still stays on the current branch $ git branch [branch-name]# Create a new branch and switch to the branch $ git checkout-b [branch]# creates a new branch, points to the specified commit$ git branch [branch] [commit]# creates a new branch, establishes a tracking relationship with the specified remote branch $ git branch--track [branch] [remote-branch]# switch to the specified branch and update the workspace $ git checkout [branch-name]# establishes a tracking relationship between the existing branch and the specified remote branch $ git branch--Set-upstream [branch] [remote-branch]# Merge specified branch to current branch $ git merge [branch]# Select a commit, merge into current branch $ git cherry-Pick [commit]# Delete branch $ git branch-D [branch-name]# Delete Remote branch $ Git push Origin--Delete $ git branch-dr
Six, label
--b [branch] [tag]
Vii. Viewing information
------Cached []# shows the difference between the work area and the current branch's latest commit $ git diff head# show two commits difference $ git diff[first
    -branch] ... [second---name-only[commit]# shows the contents of a file when a commit, git show [commit]:[filename]# shows the recent commit of the current branch $ git reflog 
Eight, remote synchronization
-----all
Ix. Revocation
-----keep [commit]# create a new commit to undo the specified commit# all changes to the latter will be offset by the former and applied to the current branch $ git revert [commit] 
X. Other
# Generate a Zip package available for release $ git archive

List of common Git commands

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.