3

I've just started a new job where they're using git-repo. There's an XML manifest file that contains all the different repos that looks like:

    <project path="company/project-name"
    name="project-name.git"
    remote="company-server"
    revision="current-branch" />

But this doesn't setup that branch for that repo. If I open the directory and type git status I get:

$ git status
HEAD detached at 1234567
nothing to commit, working tree clean

This means I can't do a git pull:

$ git pull
You are not currently on a branch.
Please specify which branch you want to merge with.

I have to do a git checkout of the correct branch to fix it:

$ git checkout current-branch
Branch 'current-branch' set up to track remote branch 'current-branch' from 'company-server'.
Switched to a new branch 'current-branch'

Then I can do git pull successfully.

Is this how git-repo is intended to work? It seems wrong to me. Or is there any way to get it to checkout the branches properly?

parsley72
  • 8,449
  • 8
  • 65
  • 98
  • 3
    Did you ask your colleagues? – jonrsharpe Mar 29 '20 at 21:40
  • 1
    I know nothing about git-repo, but a detached head is no big deal, it just means that some particular commit was checked out and is not named by any branch. And checking out a commit by its branch name is indeed what you do if you want to proceed to do anything. So, while I don't know why the repo came to you in a detached head state, I wouldn't worry about it if I were you. – matt Mar 31 '20 at 00:15

0 Answers0