# 下载一个项目和它的整个代码历史$ git clone [url]
# add specified file to staging area $ git Add [file1 ] [file2 ] . . .
# 添加当前目录的所有文件到暂存区$ git add .
# 提交暂存区到仓库区$ git commit -m [message]
< Span class= "token punctuation" ># commit staging area specified file to warehouse area $ git commit [file1 ] [file2 ] . . . -M [Message ]
# 列出所有本地分支$ git branch
# 列出所有本地分支和远程分支$ git branch -a
< Span class= "token operator" > # a new branch, but still stays in the current branch $ git branch [branch -name ]
# 新建一个分支,并切换到该分支$ git checkout -b [branch]
# Switch to the specified branch and update the workspace $ git checkout [branch-name]
< Span class= "token operator" > < Span class= "token operator" ># switch to previous branch $ git Checkout -
# Delete Branch $ git Branch - D [branch-name]
# 显示有变更的文件$ git status
# 显示当前分支的版本历史$ git log
# show code differences for staging area and Workspaces $ git diff
# Show metadata and content changes for a commit $ git show [Commit]
# 从本地master拉取代码更新当前分支:branch 一般为master
$ git rebase [branch]
#
更新远程仓储
$ git remote update
< Span class= "token punctuation" > < Span class= "token punctuation" ># retrieve changes to the remote repository and merge $ git pull with the local branch [remote ] Span class= "token punctuation" > [branch ]
< Span class= "token comment" > # upload locally designated branch to remote warehouse $ git push [ Remote ] [ Branch ]
< Span class= "token punctuation" > # reset staging area and workspace, consistent with last commit $ git reset --hard
< Span class= "token punctuation" > < Span class= "token punctuation" >
Common git commands