参考:
1.http://www.jianshu.com/p/118ce8bc6eee
2.http://www.jianshu.com/p/97946d9df5bd
CREAT(创建)
//在当前目录下创建一个本地库(Create a new local repository)
git init
//在远程库克隆一个本地库(Clone an existing repository)
git clone ssh://user@domain.tld/repo.git
Configuration(配置)
//设置提交时附带的名字(Set the name attached to all your commits)
git config [--global]user.name
//设置提交时附带的email(Set the email attached to all your commits)
git config [--global]user.email
//设置命令行输出回执的颜色(Set colorzition of command line output for all repository)
git config --globalcolor.ui auto
//获取当前库设置的用户名(Print set name(in currentrepository or globally))
git config [--global]user.name
//获取当前库设置的email(Print set email(in current repositoryor globally))
git config [--global]user.email
Local Changes(本地操作)
//查看工作区内的文件修改(List changed files in yourworking directory)
git status
//查看已追踪文件的修改(List changed to trackedfiles)
git diff
//添加此文件的所有修改在下次提交时(Add allcurrent changed in file to the next commit)
git add
//添加本地库中的所有修改在下次提交的时(Add allcurrent changed to the next commit)
git add .
//修改文件名并添加到下次提交当中(Rename file and add it tonext commit)
git mv
//删除此文件并将此处删除添加到下次提交当中(Delete fileand add its deletion to next commit)
git rm
//提交工作区所有文件(Commit all local changes in tracked files)
git commit -a
Commit History(提交历史)
//显示所有的提交日志(Show all commits)
git log
//这个文件的最后一次提交日志(Shwo changes over time fora specific file)
git log –p
//这个提交者最后一次的提交日志(Show changes over time fora specific committer)
git log--author=
//此文件被谁修改了(Who changed what and when in file)
git blame
//查看临时的文件变动(Store changes temporarily)
git stash
//删除上一次记录储蓄新的改动记录(Remove and apply changes)
git stash pop
//把此文件从过去的提交记录中删除但是保留当前本地的文件(Remvoe filefrom previous commits but keep it locally)
git rm --cached
Branches & Tags(分支和标签)
//本地所有的分支列表(List all existing branches)
git branch
//切换分支(Switch HEAD branch)
git checkout
//创建新分支(Creat a new branch based on your currentHEAD)
git branch
//创建一个新的分支基于一个远程的分支(Creat a new tracking branch based on a remote branch)
git branch --track
//删除一个本地分支(Delete a local branch)
git branch -d
//删除一个远程分支(Delete a remote branch)
git branch origin --delete
//重命名远程分支名(Rename a branch on remote)git push
git push :
//
git push
//给当前提交打一个tag,也可以查看当前标签(Tag the current commit)
git tag
Update & Publish(更新和提交)
//查看远程库的地址列表(List all currentlyconfigured remotes)
git remote -v
//查看这个远程库的信息(Show information about a remote)
git remote show
//添加新的远程库(Add new remote repository)
git remote add
//重命名远程库(Rename a remote)
git remote rename
//从远程库更新所有的信息到本地,但是不合并(Download allchanges from remote,but don't merge into HEAD)
git fetch
//从远程库更新所有的信息到本地,但是不合并并清理已删除的远程分支(Download all changes fromm remote,but don't merge inHEAD and clean up deleted branchs from origin)
git fetch -p
//从远程库更新数据并立即合并数据(Download changes and directly merge into HEAD)
git pull
//将本地数据同步到远程库中(Publish local changes on aremote)
git push
//追踪一个远程库(Track a remote repository)
git remote add --track
//同步标签到远程库(Publish your tags
git push --tags
//显示远程库信息(Show information about a submodule)
git remote show
Merge & Rebase(分支合并和重整数据)
//将其他分支和并到当前分支(Merge branch into yourcurrent HEAD)
git merge
//将亲她分支合并到当前分支并按照提交顺序排序(Rebase your current HEAD onto branch)
git rebase
//终止当前合并(Abort a rebase)
git rebase –abort
//解决冲突后继续当前合并和重整(Continue a rebase afterresolving confilcys)
git rebase –continue
//使用配置的合并工具解决冲突(Resolve conflicts using your configured merge tool)
git mergetool
//手动解决冲突使用编辑器并标记已解决的文件
git add
//
git rm
Undo(撤销)
//丢弃所有的本地修改(Discard all local changes in your workingdirectory)
git reset --hard HEAD
//丢弃此文件的本地修改(Discard local changes in aspecific file)
git checkout HEAD
//撤销某次的提交内容(Revert a commit by providing a new commit with contrary changes)
git revert
//撤销某次提交的某个文件的内容(Revert a specific filefrom a previous commit)
git checkout
重置头指针到过去的某个提交上,版本回退(Reset your HEAD pointer to a previous commit)
//回退到某个版本(Discarding local changes)
git reset --hard
//回退到某个版本并保存未追踪的改动
git reset
//回退到某个版本并保存未提交的改动
git reset --keep