user2599522
user2599522

Reputation: 3215

Unable to checkout a branch with repo tool

I'm trying to check out a branch using repo tool. The steps I'm following are:

  1. initialize the repository

    repo init -u https://meh

  2. sync it

    repo sync

  3. start master for all projects

    repo start master --all

Now one of the repositories looks like this:

*   4d35068 4 hours ago (user1)         (HEAD, m/master, git-server/master, master)   Merge branch 'BUG-1234' into 'master'
|\                                                                  
| |                                                                 
| * 5f5bef7 4 hours ago (user1)         (git-server/BUG-1234)   BUG-1234: fixing something
| |                                                                 
* | 86aa598 4 hours ago (user2)           BUG-1235: Bug fixing      
| |                                                                 
* | 9a5511d 5 hours ago (user2)           BUG-1235: fixing something
| |                                                                 
| |                                                                 
* | 6a9a6c5 5 hours ago (user2)           BUG-1235: fixing something 
|/                                                                  
|                                                                   
* 33d9c96 7 hours ago (user2)     BUG-1235: fixing code     
  1. Try to checkout branch BUG-1234 with

    repo checkout BUG-1234

The issue im facing at this point iss that HEAD is not pointing to 5f5bef7 as i would expect, but to 4d35068

*   4d35068 4 hours ago (user1)         (HEAD, m/master, git-server/master, topbeat-b1, master, BUG-1234)   Merge branch 'BUG-1234' into 'master'
|\                                                                  
| |                                                                 
| * 5f5bef7 4 hours ago (user1)         (git-server/BUG-1234)   BUG-1234: fixing something
| |                                                                 
* | 86aa598 4 hours ago (user2)           BUG-1235: Bug fixing      
| |                                                                 
* | 9a5511d 5 hours ago (user2)           BUG-1235: fixing something
| |                                                                 
| |                                                                 
* | 6a9a6c5 5 hours ago (user2)           BUG-1235: fixing something 
|/                                                                  
|                                                                   
* 33d9c96 7 hours ago (user2)     BUG-1235: fixing code                      

I think I haven't told repo tool how to map the two branches but I'm not sure if/how I can do that.


Expected result after repo checkout BUG-1234:

*   4d35068 4 hours ago (user1)         (HEAD, m/master, git-server/master, topbeat-b1, master)   Merge branch 'BUG-1234' into 'master'
|\                                                                  
| |                                                                 
| * 5f5bef7 4 hours ago (user1)         (git-server/BUG-1234, BUG-1234)   BUG-1234: fixing something
| |                                                                 
* | 86aa598 4 hours ago (user2)           BUG-1235: Bug fixing      
| |                                                                 
* | 9a5511d 5 hours ago (user2)           BUG-1235: fixing something
| |                                                                 
| |                                                                 
* | 6a9a6c5 5 hours ago (user2)           BUG-1235: fixing something 
|/                                                                  
|                                                                   
* 33d9c96 7 hours ago (user2)     BUG-1235: fixing code           

Upvotes: 1

Views: 1450

Answers (1)

gzh
gzh

Reputation: 3596

repo checkout BUG-1234 will create a local branch based on local branch `master'.

Please use the following command to create local branch to track remote branch.

git checkout --track git-server/BUG-1234

By the way, you can use the following command to check whether your local branch is tracking a remote branch.

git branch -a -vv

Upvotes: 1

Related Questions