repo sync 切换分支问题


在使用repo和git管理android源码过程中。个人遇到一些问题:1.使用repo sync pro时候会切换分支:比如当前我的目录在frameworks/base

使用 git branch -a

  KK1.MP15.V1.34
* ppbox-mtk15

目前在frameworks/base我有两个分支并且两个分支跟踪的远程分支分别为

git br = git branch

git br -vv 
  KK1.MP15.V1.34 237c569 [ppbox/KK1.MP15.V1.34] [PPBOX-111] ALPS01862086(For_PPTV85_BX_KK_ALPS.KK1.MP15.V1.34_P10).tar.gz
* ppbox-mtk15    48bbab2 [ppbox/ppbox-mtk15] [PPBOX-2593] mini支持wifi中文ssid连接 ALPS01862086(For_PPTV85_BX_KK_ALPS.KK1.MP15.V1.34_P10).tar.gz

KK1.MP15.V1.34 跟踪远程分支 ppbox/KK1.MP15.V1.34

ppbox-mtk15跟踪远程分支 ppbox/ppbox-mtk15

切换分支到 KK1.MP15.V1.34 上,git checkout KK1.MP15.V1.34


 

* KK1.MP15.V1.34
  ppbox-mtk15


这时候使用 repo sync .更新frameworks/base时候发现

Fetching project platform/frameworks/base

frameworks/base/: manifest switched refs/heads/KK1.MP15.V1.34...ppbox-mtk15
project frameworks/base/

It seems that there is already a rebase-apply directory, and
I wonder if you are in the middle of another rebase.  If that is the
case, please try
        git rebase (--continue | --abort | --skip)
If that is not the case, please
      <pre class="html" name="code">  rm -fr /home/biaolv/ptest/mtk15_patch/frameworks/base/.git/rebase-apply
and run me again. I am stopping in case you still have somethingvaluable there.
 

使用命令

rm -fr /home/biaolv/ptest/mtk15_patch/frameworks/base/.git/rebase-apply


后在repo  sync.由出现

Fetching project platform/frameworks/base

project frameworks/base/
First, rewinding head to replay your work on top of it...
Applying: [PPBOX-111] ALPS01860827(For_PPTV85_BX_KK_ALPS.KK1.MP15.V1.34_P3).tar.gz
Using index info to reconstruct a base tree...
<stdin>:149: trailing whitespace.
/// M: set max volume when class is loaded @{    
<stdin>:207: trailing whitespace.
            flags = flags | AudioManager.FLAG_SHOW_UI;    
<stdin>:265: trailing whitespace.
                } else {                   
<stdin>:267: trailing whitespace.
                    if (FeatureOption.MTK_CMCC_OTT_SUPPORT) {               
<stdin>:269: trailing whitespace.
                    } 
warning: squelched 7 whitespace errors
warning: 12 lines add whitespace errors.
Falling back to patching base and 3-way merge...
Auto-merging media/java/android/media/AudioService.java
CONFLICT (content): Merge conflict in media/java/android/media/AudioService.java
Resolved 'media/java/android/media/AudioService.java' using previous resolution.
Failed to merge in the changes.
Patch failed at 0001 [PPBOX-111] ALPS01860827(For_PPTV85_BX_KK_ALPS.KK1.MP15.V1.34_P3).tar.gz

When you have resolved this problem run "git rebase --continue".
If you would prefer to skip this patch, instead run "git rebase --skip".
To check out the original branch and stop rebasing run "git rebase --abort".


操!!!竟然发现
manifest switched refs/heads/KK1.MP15.V1.34...ppbox-mtk15 发现竟然把当前分支追踪分支切换了!!

通过 cat  .git/config


 

[branch "ppbox-mtk15"]
        remote = ppbox
        
[branch "KK1.MP15.V1.34"]
        remote = ppbox
        merge = ppbox-mtk15


发现KK1.MP15.V1.34跟踪ppbox-mtk15这个分支了。这个分支从哪来的呢??

在 androidroot目录下 cat .repo/manifest.xml

<?xml version="1.0" encoding="UTF-8"?>
<manifest>

  <remote  name="ppbox"
           fetch=".."
           review="ssh://innrom.pptv.com/ppbox/mtk/" />
  <default revision="ppbox-mtk15"
           remote="ppbox"
           sync-j="1" />

原来是把控制项目的版本库的分支的远程分支切换为KK1.MP15.V1.34的远程分支 ,

从这句话也可以得出这个结论switched refs/heads/KK1.MP15.V1.34...ppbox-mtk15。

如果想切换为原来分支可以使用下面命令

git reset --hard ppbox/KK1.MP15.V1.34

然后在vim  .git/config

[branch "KK1.MP15.V1.34"]        
remote = ppbox        
merge = ppbox-mtk15
修改如下
[branch "ppbox-mtk15"]
    remote = ppbox
    merge = refs/heads/ppbox-mtk15
[branch "KK1.MP15.V1.34"]
    remote = ppbox
    merge = refs/heads/KK1.MP15.V1.34
~                                      


如果避免这种问题呢??

在ppbox-mtk15分支上你使用repo sync 是没有问题的。因为远程分支相同。对于 KK1.MP15.V1.34 就不行了。你可以使用 git pull 来更新版本。

那有没有更好方法呢??

有网友说可以修改

diff --git a/project.py b/project.py
index 22e4a5d..3ce6500 100644
--- a/project.py
+++ b/project.py
@@ -1169,6 +1169,8 @@ class Project(object):
        syncbuf.info(self,
                      'manifest no longer tracks %s',
                      branch.merge)
+      syncbuf.fail(self, "branch is not consistent:%s, %s" %(branch.merge, self.revisionExpr))  
+      return
 
    if cnt_mine < len(local_changes):
      # Upstream rebased.  Not everything in HEAD

that's all

具体这个方法管不管用。我不敢试!!希望有人试用一下,能告诉结果让后来人犯同样错误

文件路径
.repo/repo/project.py

 

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

九霄的爸爸

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值