repo,git相关命令使用

来源:互联网 发布:程序员必备的手机app 编辑:程序博客网 时间:2024/06/06 13:24

git download

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

repo:

repo命令参数:

  abandon        Permanently abandon a development branch  branch         View current topic branches  branches       View current topic branches  checkout       Checkout a branch for development  cherry-pick    Cherry-pick a change.  diff           Show changes between commit and working tree  diffmanifests  Manifest diff utility  download       Download and checkout a change  forall         Run a shell command in each project  gitc-delete    Delete a GITC Client.  gitc-init      Initialize a GITC Client.  grep           Print lines matching a pattern  help           Display detailed help on a command  info           Get info on the manifest branch, current branch or unmerged branches  init           Initialize repo in the current directory  list           List projects and their associated directories  manifest       Manifest inspection utility  overview       Display overview of unmerged project branches  prune          Prune (delete) already merged topics  rebase         Rebase local branches on upstream branch  selfupdate     Update repo to the latest version  smartsync      Update working tree to the latest known good revision  stage          Stage file(s) for commit  start          Start a new branch for development  status         Show the working tree status  sync           Update working tree to the latest revision  upload         Upload changes for code review  version        Display the version of repo

git:

git命令参数:

add                       clone                     fetch-pack                ls-files                  notes                     remote-http               stashadd--interactive          column                    filter-branch             ls-remote               p4                        remote-https              statusam                        commit                    fmt-merge-msg             ls-tree                   pack-objects              remote-testsvn            stripspaceannotate                  commit-tree               for-each-ref              mailinfo                  pack-redundant            repack                    submoduleapply                     config                    format-patch              mailsplit                 pack-refs                 replace                   subtreearchive                   count-objects             fsck                      merge                     patch-id                  request-pull              symbolic-refbisect                    credential                fsck-objects              merge-base                prune                     rerere                    tagbisect--helper            credential-cache          gc                        merge-file                prune-packed              reset                     unpack-fileblame                     credential-cache--daemon  get-tar-commit-id         merge-index               pull                      rev-list                  unpack-objectsbranch                    credential-store          grep                      merge-octopus             push                      rev-parse                 update-indexbundle                    daemon                    hash-object               merge-one-file            quiltimport               revert                    update-refcat-file                  describe                  help                      merge-ours                read-tree                 rm                        update-server-infocheck-attr                diff                      http-backend              merge-recursive           rebase                    send-pack                 upload-archivecheck-ignore              diff-files                http-fetch                merge-resolve             receive-pack              sh-i18n--envsubst         upload-packcheck-mailmap             diff-index                http-push                 merge-subtree             reflog                    shell                     varcheck-ref-format          diff-tree                 imap-send                 merge-tree                relink                    shortlog                  verify-packcheckout                  difftool                  index-pack                mergetool                 remote                    show                      verify-tagcheckout-index            difftool--helper          init                      mktag                     remote-ext                show-branch               web--browsecherry                    fast-export               init-db                   mktree                    remote-fd                 show-index                whatchangedcherry-pick               fast-import               instaweb                  mv                        remote-ftp                show-ref                  write-treeclean                     fetch                     log                       name-rev                  remote-ftps               stage

git常用命令:

The most commonly used git commands are:   add        Add file contents to the index   bisect     Find by binary search the change that introduced a bug   branch     List, create, or delete branches   checkout   Checkout a branch or paths to the working tree   clone      Clone a repository into a new directory   commit     Record changes to the repository   diff       Show changes between commits, commit and working tree, etc   fetch      Download objects and refs from another repository   grep       Print lines matching a pattern   init       Create an empty Git repository or reinitialize an existing one   log        Show commit logs   merge      Join two or more development histories together   mv         Move or rename a file, a directory, or a symlink   pull       Fetch from and integrate with another repository or a local branch   push       Update remote refs along with associated objects   rebase     Forward-port local commits to the updated upstream head   reset      Reset current HEAD to the specified state   rm         Remove files from the working tree and from the index   show       Show various types of objects   status     Show the working tree status   tag        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 indexA   added   not in HEAD, in indexM   modified    in HEAD, modified in indexD   deleted in HEAD, not in indexR   renamed not in HEAD, path changed in indexC   copied  not in HEAD, copied from another in indexT   mode changed    same content in HEAD and index, mode changedU   unmerged    conflict between HEAD and index; resolution required每二个字符表示工作区的状态 letter  meaning description-   new/unknown not in index, in work treem   modified    in index, in work tree, modifiedd   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

原创粉丝点击