repo常用相关命令

repo常用相关命令

1、repo start

     开启一个新的主题,其实就是每个Project都新建一个分支。

     repo start newbranchname .

      创建新的branch分支。 "." 代表当前工作的branch 分支。

2、repo init -u [OPTIONS]

       repo init -u git://android.git.kernel.org/platform/manifest.git

  repo init -u URL 用以在当前目录安装 repository ,会在当前目录创建一个目录 ".repo"  -u 参数指定一个URL, 从这个URL 中取得repository 的 manifest 文件。

   在当前目录下初始化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 -u git://android.git.kernel.org/platform/manifest.git -m dalvik-plus.xml

   可以用 -m 参数来选择获取 repository 中的某一个特定的 manifest 文件,如果不具体指定,那么表示为默认的 namifest 文件 (default.xml)

         repo init -u git://android.git.kernel.org/platform/manifest.git -b release-1.0

     可以用 -b 参数来指定某个manifest 分支。

3、repo manifest

  可以根据当前各Project的版本信息生成一个manifest文件

4、repo sync [PROJECT1...PROJECTN]

  下载最新本地工作文件,更新成功,这本地文件和repository 中的代码是一样的。 可以指定需要更新的project , 如果不指定任何参数,会同步整个所有的项目。

  如果是第一次运行repo sync , 则这个命令相当于 git clone ,会把 repository 中的所有内容都拷贝到本地。 如果不是第一次运行repo sync , 则相当于 git remote update ;  git   rebase origin/branch .  repo sync 会更新 .repo 下面的文件。 如果在merge 的过程中出现冲突, 这需要手动运行  git  rebase

--continue

举例: repo sync -j8 prebuilts/maven_repo/android

5、repo status

  显示 project 中每个仓库的状态,并打印仓库名称。

  查看本地所有Project的修改,在每个修改的文件前有两个字符,第一个字符表示暂存区的状态。

- 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

6、repo prune

  删除已经merge的分支

7、repo abandon

  删除分支,无论是否merged

8、repo branch或repo branches

  查看所有分支

9、repo diff

  查看修改

repo diff platform/build platform/bionic  ---只查看其中两个项目

10、repo upload

  上传本地提交至服务器

11、repo forall [PROJECT_LIST]-c COMMAND

  对指定的Project列表或所有Project执行命令COMMAND,加上-p参数可打印出Project的路径。

12、repo forall -c 'git reset --hard HEAD;git clean -df;git rebase --abort'

repo forall –c ‘git remote add korg ssh://[email protected]/$REPO_PROJECT.git’

  这个命令可以撤销整个工程的本地修改。

13、repo forall -c

  遍历所有的git仓库,并在每个仓库执行-c所指定的命令(被执行的命令不限于git命令,而是任何被系统支持的命令,比如:ls 、 pwd 、cp 等 。

14、repo forall -c git checkout -b  本地分支名称(自定义)  服务器分支名称

  下载新的分支

15、repo forall -c git checkout your_branch

  切换到另外一个分支

16、repo forall -c git branch -D  分支名称

  删除分支

17、repo forall -c git git reset --hard HEAD

  丢弃修改

18、repo  forall -r kernel/linux-3.10.y bootable/bootloader/uboot-2015.04  -c git reset --hard HEAD

  对指定的仓进行操作,-r后跟仓名

19、repo forall -p -c git branch 

  repo执行的时候加上-p参数就可以在遍历到每个仓库的时候先打印出当前的pwd,然后再继续执行-c所指定的命令。

repo forall -c ‘echo $REPO_PROJECT’

  添加环境变量。

20、repo foreach [ project-lists] -c command

       对每一个 project 运行 command 命令

21、repo download  target revision

        下载特定的修改版本到本地, 例如:  repo download pltform/frameworks/base 1241 下载修改版本为 1241 的代码

22、repo remote

  设置远程仓库

repo remote add   […]

repo remote rm   […]

repo remote add org ssh://172.16.1.31/git_repo

  这个指令是根据xml文件添加的远程分支,方便于向服务器提交代码,执行之后的build目录下看到新的远程分支org

repo  remote  rm  org

  删除远程仓库

23、repo push

  向服务器提交代码

repo push org

repo push [--all |…]

  repo会自己查询需要向服务器提交的项目并提示用户。

24、repo manifest

  显示manifest文件内容

repo manifest -o android.xml

你可能感兴趣的:(repo常用相关命令)