###git download
[https://git-scm.com/downloads]

#repo:
repo命令参数:

  abandon        Permanently abandon a development branchbranch         View current topic branchesbranches       View current topic branchescheckout       Checkout a branch for developmentcherry-pick    Cherry-pick a change.diff           Show changes between commit and working treediffmanifests  Manifest diff utilitydownload       Download and checkout a changeforall         Run a shell command in each projectgitc-delete    Delete a GITC Client.gitc-init      Initialize a GITC Client.grep           Print lines matching a patternhelp           Display detailed help on a commandinfo           Get info on the manifest branch, current branch or unmerged branchesinit           Initialize repo in the current directorylist           List projects and their associated directoriesmanifest       Manifest inspection utilityoverview       Display overview of unmerged project branchesprune          Prune (delete) already merged topicsrebase         Rebase local branches on upstream branchselfupdate     Update repo to the latest versionsmartsync      Update working tree to the latest known good revisionstage          Stage file(s) for commitstart          Start a new branch for developmentstatus         Show the working tree statussync           Update working tree to the latest revisionupload         Upload changes for code reviewversion        Display the version of repo

#git:
git命令参数:

add                       clone                     fetch-pack                ls-files                  notes                     remote-http               stash
add--interactive          column                    filter-branch             ls-remote
p4                        remote-https              status
am                        commit                    fmt-merge-msg             ls-tree                   pack-objects              remote-testsvn            stripspace
annotate                  commit-tree               for-each-ref              mailinfo                  pack-redundant            repack                    submodule
apply                     config                    format-patch              mailsplit                 pack-refs                 replace                   subtree
archive                   count-objects             fsck                      merge                     patch-id                  request-pull              symbolic-ref
bisect                    credential                fsck-objects              merge-base                prune                     rerere                    tag
bisect--helper            credential-cache          gc                        merge-file                prune-packed              reset                     unpack-file
blame                     credential-cache--daemon  get-tar-commit-id         merge-index               pull                      rev-list                  unpack-objects
branch                    credential-store          grep                      merge-octopus             push                      rev-parse                 update-index
bundle                    daemon                    hash-object               merge-one-file            quiltimport               revert                    update-ref
cat-file                  describe                  help                      merge-ours                read-tree                 rm                        update-server-info
check-attr                diff                      http-backend              merge-recursive           rebase                    send-pack                 upload-archive
check-ignore              diff-files                http-fetch                merge-resolve             receive-pack              sh-i18n--envsubst         upload-pack
check-mailmap             diff-index                http-push                 merge-subtree             reflog                    shell                     var
check-ref-format          diff-tree                 imap-send                 merge-tree                relink                    shortlog                  verify-pack
checkout                  difftool                  index-pack                mergetool                 remote                    show                      verify-tag
checkout-index            difftool--helper          init                      mktag                     remote-ext                show-branch               web--browse
cherry                    fast-export               init-db                   mktree                    remote-fd                 show-index                whatchanged
cherry-pick               fast-import               instaweb                  mv                        remote-ftp                show-ref                  write-tree
clean                     fetch                     log                       name-rev                  remote-ftps               stage

git常用命令:

The most commonly used git commands are:add        Add file contents to the indexbisect     Find by binary search the change that introduced a bugbranch     List, create, or delete branchescheckout   Checkout a branch or paths to the working treeclone      Clone a repository into a new directorycommit     Record changes to the repositorydiff       Show changes between commits, commit and working tree, etcfetch      Download objects and refs from another repositorygrep       Print lines matching a patterninit       Create an empty Git repository or reinitialize an existing onelog        Show commit logsmerge      Join two or more development histories togethermv         Move or rename a file, a directory, or a symlinkpull       Fetch from and integrate with another repository or a local branchpush       Update remote refs along with associated objectsrebase     Forward-port local commits to the updated upstream headreset      Reset current HEAD to the specified staterm         Remove files from the working tree and from the indexshow       Show various types of objectsstatus     Show the working tree statustag        Create, list, delete or verify a tag object signed with GPG

#Android repo版本管理相关操作:

repo 构建本地版本管理:

//$repo init -u <url> [OPTIONS]
/**在当前目录下初始化repo,会在当前目录生生成一个.repo目录,像Git Project下的.git一样,-u指定url,可以加参数-m指定manifest文件,默认是default.xml,.repo/manifests保存manifest文件。.repo/projects下有所有的project的数据信息,repo是一系列git project的集合,每个git project下的.git目录中的refs等目录都是链接到.repo/manifests下的。**/$repo init xxxxx // 初始化repo
$repo sync  //同步远程仓库代码,下载代码。$repo start newbranch --all //创建repo分支 --all所有manifest project, 也可以指定project.
$repo checkout otherbranch //检出到otherbranch分支, $repo diff  //显示差异,只对已跟踪的文件有效,
$repo status //显示当前分支状态
第一个字符表示暂存区的状态。
-   no change   same in HEAD and index
A   added   not in HEAD, in index
M   modified    in HEAD, modified in index
D   deleted in HEAD, not in index
R   renamed not in HEAD, path changed in index
C   copied  not in HEAD, copied from another in index
T   mode changed    same content in HEAD and index, mode changed
U   unmerged    conflict between HEAD and index; resolution required
每二个字符表示工作区的状态
letter  meaning description
-   new/unknown not in index, in work tree
m   modified    in index, in work tree, modified
d   deleted in index, not in work tree$repo prune <topic> //删除已经merge的分支
$repo abandon <topic> //删除分支,无论是否merged,比较危险,建议少用!!!
$repo branch或repo branches //查看所有分支
$repo upload //上传本地提交至服务器//$repo forall [PROJECT_LIST]-c COMMAND
//对指定的Project列表或所有Project执行命令COMMAND,加上-p参数可打印出Project的路径。
//repo遍历所有project 执行git 命令操作
$repo forall -c <git command>
$repo forall -c git merge other // 将other分支合并到当前分支
$repo forall -c git branch -m oldname newname //重命名分支
$repo forall -c git branc -D branchname //删除分支$repo manifest  //可以根据当前各Project的版本信息生成一个manifest文件
$repo manifest -o - //查看manifest 清单

###git代码审核:
可以使用下面的配置来关闭代码检查:
git config core.autocrlf true

git config core.safecrlf true

还可以在提交代码时禁止代码检查:
git commit --no-verify-a

也可以这样做:
git config core.whitespace “trailing-space,space-before-tab”
git config apply.whitespace “trailing-space,space-before-tab”

还有另外一个办法,就是在pre-commit添加如下语句:
if(/\s$/){#bad_line(“trailing whitespace”, $_);}

退回到某一提交:(要慎用会删掉退回处之前的所有提交)

git reset --hard <commit_id>

取消跟踪已版本控制的文件

git 不再追踪文件改动 git update-index --assume-unchanged filePathgit 恢复追踪文件改动 git update-index —no-assume-unchanged filePathgit 删除被管理的文件 git rm —cached filePathgit 删除被管理的文件夹 git rm -r -f —cached filePathGit 是一个很好的版本控制工具,当然驾驭起来相比 SVN 要稍微复杂一些。初入 Git,难免有一些问题。比如我们不小心将某个文件加入了版本控制,但是突然又不想继续跟踪控制这个文件了,怎么办呢?其实方法也是很简单的。使用git update-index 即可。不想继续追踪某个文件git update-index --assume-unchanged your_file_path
如果想再次继续跟踪某个文件git update-index --no-assume-unchanged your_file_path提交当前目录git仓库到远端服务器:
git remote add origin in http://192.168.199.111:9090/git/xxx/xxx_linux.git
git push -u origin master
git push -f origin master  //(non-fast-forward)出现冲突强推!!!git push origin test:master         // 提交本地test分支作为远程的master分支
git push origin test:test              // 提交本地test分支作为远程的test分支保存用户密码:
git config --global credential.helper store查看远端分支:
git branch -rfetch远程demo分支到本地test分支,(test分支原先并不存在)
git fetch origin demo:test更改远端git仓库
git remote remove origin
git remote add origin git@xxx:xxx.git
git push origin master常用git 工具:
gitlab, sourcetree

补丁生成与打补丁:

生成补丁:

方法1 $git format-patch 9cd15047c* //生成当前提交之前的差分补丁
方法2 $git show 4ff7d9ce* > 0001.patch //生成本次提交的差分补丁,文件名为0001.patch

手动打补丁:
1.先检查patch文件:git apply --stat newpatch.patch
2.检查能否应用成功:git apply --check newpatch.patch
3.打补丁:git am --signoff < newpatch.patch (使用-s或–signoff选项,可以commit信息中加入Signed-off-by信息)
4.以上命令打补丁失败有冲突,可以手动打补丁:
$patch -p1 < 0002-1.patch

git format-patch:
$ git format-patch HEAD^               #生成最近的1次commit的patch
$ git format-patch HEAD^^              #生成最近的2次commit的patch
$ git format-patch HEAD^^^              #生成最近的3次commit的patch
$ git format-patch HEAD^^^^             #生成最近的4次commit的patch
$ git format-patch … #生成两个commit间的修改的patch(包含两个commit. 和都是具体的commit号)
$ git format-patch -1 #生成单个commit的patch
$ git format-patch #生成某commit以来的修改patch(不包含该commit)
$ git format-patch --root              #生成从根到r1提交的所有patch

git am:
$ git apply --stat 0001-limit-log-function.patch      # 查看patch的情况
$ git apply --check 0001-limit-log-function.patch     # 检查patch是否能够打上,如果没有任何输出,则说明无冲突,可以打上
(注:git apply是另外一种打patch的命令,其与git am的区别是,git apply并不会将commit message等打上去,打完patch后需要重新git add和git commit,而git am会直接将patch的所有信息打上去,而且不用重新git add和git commit,author也是patch的author而不是打patch的人)
$ git am 0001-limit-log-function.patch # 将名字为0001-limit-log-function.patch的patch打上
$ git am --signoff 0001-limit-log-function.patch # 添加-s或者–signoff,还可以把自己的名字添加为signed off by信息,作用是注明打patch的人是谁,因为有时打patch的人并不是patch的作者
$ git am ~/patch-set/.patch             # 将路径~/patch-set/.patch 按照先后顺序打上
$ git am --abort # 当git am失败时,用以将已经在am过程中打上的patch废弃掉(比如有三个patch,打到第三个patch时有冲突,那么这条命令会把打上的前两个patch丢弃掉,返回没有打patch的状态)
$ git am --resolved #当git am失败,解决完冲突后,这条命令会接着打patch

repo,git相关命令使用相关推荐

  1. Git相关命令及用法

    add commit push git add * git commit -m "" git push -u origin branch 在删除某一些文件时, 应使用git add ...

  2. Git npm相关命令

    Git 相关命令 查看用户名和密码 配置用户名和密码 查看git项目远程地址 添加git远程仓库 查看提交记录 查看已有tag 打标签 在某次提交记录上打标签 推送标签到远程 推送单个指定tag到远程 ...

  3. git常用命令操作方法

    git命令–切换分支 https://blog.csdn.net/qq_38335037/article/details/82755912?utm_medium=distribute.pc_relev ...

  4. Linux下python的命令,linux下python相关命令

    若本机已安装python2,尽量不要动现有的python2,额外安装python3即可. 1.安装python3.6(centos下安装python3自带pip和setuptools) # 安装依赖环 ...

  5. g-git 相关命令 及其 基本原理探索(二):git 在工作中的常用命令操作 ,超级实用!!!

    上一篇git 基本原理对git的使用以及文件分布已经有了一个整体的了解. 本篇将对工作中常用的一些git 操作命令的操作进行总结归纳,方便今后查阅. 文章目录 1. 分离头指针 2. 通过HEAD 来 ...

  6. git分支(branch)操作相关命令

    分支(branch)操作相关命令 查看本地分支:$ git branch 查看远程分支:$ git branch -r 创建本地分支:$ git branch [name] ----注意新分支创建后不 ...

  7. Git 相关使用命令

    全局设置 git config --global user.name "zyl" git config --global user.email xxx@xxx.com git co ...

  8. Git 回退撤销相关命令,毫无保留,都在这里了!!!

    Git 回退撤销相关命令 # 恢复暂存区的指定文件到工作区 # 即让 工作区的文件 和 暂存区的保持一致,回到初始状态 git checkout [file]# 恢复某个commit的指定文件到暂存区 ...

  9. 【git】vscode敲stash相关命令Too many revisions specified

    在vscode终端敲stash的相关命令总会遇到报错提示,这一次报错 git stash show -p stash@{0} //执行的命令 Too many revisions specified: ...

最新文章

  1. day19_MD5加密_Apache DBUtils_监听器 知识回顾
  2. shell之$@和$*的区别
  3. 关于 Unity WebGL 的探索
  4. 关闭被占用的tomcat端口
  5. 《认识电子计算机》的教学设计,认识计算机教学设计
  6. jquery 扩展ajax请求,jQuery如何管理、扩展AJAX请求
  7. windows下的wxWidgets环境配置
  8. 转载--32个鲜为人知的自学网站
  9. 转子系统动力学模型matlab程序代码
  10. VTK系列57_VTK对几何体网格细化(多分辨率处理)
  11. 如何直接修改html文件,如何修改HTML的文件?
  12. 网站别黑了怎么解决?如何处理网站被黑问题详解
  13. 方舟非主机服务器无限距离,方舟生存进化怎么调主机距离
  14. 解决Can not add resource (com.android.aaptcompiler.ParsedResource@a980fbb) to table
  15. Java零散知识点记录——类的方法
  16. 出国(澳大利亚)要求材料
  17. 详谈气象站的功能区别
  18. free pascal
  19. Packet Tracer - 配置扩展 ACL - 场景 1
  20. NLP_learning 中文基本任务与处理(分词、停用词、词性标注、语句依存分析、关键词抽取、命名实体识别)介绍、jieba工具库

热门文章

  1. NetApp AFF A 系列全闪存存储阵列
  2. video视频兼容苹果和安卓
  3. [paper]Defense against Adversarial Attacks Using High-Level Representation Guided Denoiser
  4. android平板电脑手写笔应用,四款最佳手写笔平板推荐
  5. Filter过滤器讲解
  6. 简单的爬取某租房网站租房信息并存入MySQL数据库
  7. 签到方式出“新招”!人脸识别考勤系统
  8. 【二次开发教程】Ai-WB2系列的eclipes搭建环境教程
  9. win10找回图片查看器
  10. 【实战场景】商城-折扣活动设计方案