Wen/Nanyi
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]"
三、增加/删除文件
--Cached [file]# renamed the file and put this name in staging area $ git mv [file-original] [file-renamed]
四、代码提交
------amend---amend ...
五、分支
# 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
六、标签
--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
九、撤销
-----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]
十、其他
# Generate a Zip package available for release $ git archive
Finish http://news.cnblogs.com/n/534449/
Common git Commands list (go)