1

I have wrote an XML file to fetch the source code on particular branch with particular commit ID. Below is the XML file,

<?xml version="1.0" encoding="UTF-8"?>
        <manifest>
                <remote name="origin" fetch="<url>" />
                <default remote="origin" revision="/refs/heads/branch-name" sync-j="4"/>
                <project name="<File-Name>" revision="14c105cba01f69cb957489413d2f80b3216a870" />
        </manifest>

I fetched the code using below repo commands,

repo init -u (path-to-xml-file) -m fetch.xml
repo sync
  • When I do git branch at the cloned directory, it is showing as "*no branch"

How should I modify the XML file, so that I can get the branch name as mentioned in the XML file while executing git branch ??

1 Answers1

0

In order to keep the status with that you specified in manifest.xml, repo will checkout source code in a "detached header" state, by which when you run git branch, it is showing as "no branch".

you can find the branch by git branch -a, there is a branch name shown as

remotes/m/master -> your_remote_name/your_branch

which is your branch specified in manifest.xml.

you can run the following command to switch all your worktree to a regular branch.

repo forall -pc 'git checkout --track $REPO_REMOTE/$REPO_RREV'

gzh
  • 3,507
  • 2
  • 19
  • 23