Git

---------------------创建版本库--------------------------------------------------

git   clone   <url>           #克隆远端版本库

git    init                        # 初始化本地版本库

---------------------修改和提交---------------------------------------------------

git    status                    #查看当前工作区间状态

git    diff                         #查看变更内容

git    mv   <old>   <new>   #修改文件名

git    rm   <file>                #删除文件

git    rm    --cached    <file>  #停止跟踪文件但不删除

git     checkout    -- <file>  #丢掉某个修改的文件(回退到修改之前的状态)

git     add    <file>              #添加文件到索引库

git    commit                  #当我们使用git commit时,git将依据索引库中的内容来进行文件的提交

git    commit    --amend    #追加到上一次提交

---------------------查看提交历史记录----------------------------------------------

git    log                        #查看提交历史记录

git   log   -p   <file>           #查看某个文件的提交历史记录

git   blame   <file>          #以列表的形式查看某个文件的提交历史记录【追责】

---------------------撤销-----------------------------------------------------------------

git   reset   [--hard|--soft|--mixed]   HEAD^       #撤销提交信息

git revert <commitid>    #撤销指定的提交

---------------------合并代码-------------------------------------------------------------

git   rebase <branch>   合并当前代码到branch

---------------------分支与标签----------------------------------------------------------

git   branch                # 查看本地所有分支

git   checkout  <branch/tag>   #切换到指定的分支或者标签

git   branch  <newBranchName>   #新建分支

git  branch  [-d|-D]  <branchName>   #删除分支

git tag    #列出所有本地标签

git  tag   <newTagName>   #基于最新提交创建标签

git  tag   -d  <tagName>   # 删除标签

---------------------远程操作-----------------------------------------------------------

git   push    origin   HEAD:refs/for/master         #推送到远端git(gerrit)

get    cherry-pick   <commit-id>   拉取远端【或者本地】的某次提交历史记录

git   remote   -v  #查看远程版本库信息

git   remote show <remote>  #查看指定远程版本库信息

git   remote   add  <remote>  <url>   添加远程版本库

git  fetch  <remote>  #从远程代码库获取代码

git  pull  <remote>   <branch>   #下载代码

附上一张图:

原文地址:https://www.cnblogs.com/QQ931697811/p/7047964.html