Repo: Missing .git/HEAD

2,031 views
Skip to first unread message

Neil Perry

unread,
Jan 11, 2011, 4:01:31 PM1/11/11
to Android Building
Evening,

As I live in the countryside my internet connection is slow, It takes
me two hours for a fresh repo sync. But something has gone wrong, this
error didn't show until at the end. Seem to be missing a .git/HEAD.

I'm not a repo/git expert, wonder if this can fixed without another
2-3hour fresh repo sync.


IOError: [Errno 2] No such file or directory: u'/home/neil/Projects/
android/system/external/bouncycastle/.git/HEAD'

Thanks

Neil

Jean-Baptiste Queru

unread,
Jan 11, 2011, 4:16:33 PM1/11/11
to android-...@googlegroups.com
Yup, there's definitely a way.

Short answer: rm -rf external/bouncycastle ; repo sync

If that doesn't work: rm -rf external/bouncycastle
.repo/projects/external/bouncycastle.git ; repo sync

Long answer:

repo stores the "true" .git repositories under .repo/projects. This is
where the "heavy" objects are.

It then sets up "fake" .git repositories in the live source tree, so
that git commands run from inside the source tree automagically find
which project to refer to. Those "fake" .git repositories are mostly
(but not entirely) symlinks to the "true" ones.

Sometimes, the "true" git repository doesn't get set up properly, and
the setup for the "fake" one leaves it in a dirty state. In such
situations, deleting the "fake" one and/or the "true" one will snap
things back in order without touching the other 150+ projects.

Note1 (not for the faint of heart): running "rm -rf *" from the root
of the source tree isn't supposed to delete .repo, so a subsequent
repo sync will restore a pristine source tree with minimal network
access. This is a great way to save disk space without causing massive
future network usage. Before you do that, you want to run "echo *" to
make sure that your shell does the right thing, as that's really a
scary command.

Note2: the contents of .repo/projects are mostly branch-agnostic. If
you have e.g. a froyo client and you want a gingerbread client next to
it, you can copy .repo/projects from your froyo client to the new
gingerbread one between repo init and repo sync. There's even a
project to share .repo/projects even further but that's not current
yet.

If bandwidth is really expensive, it might even make sense so keep a
backup copy of .repo/projects.

JBQ

> --
> You received this message because you are subscribed to the "Android Building" mailing list.
> To post to this group, send email to android-...@googlegroups.com
> To unsubscribe from this group, send email to
> android-buildi...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/android-building?hl=en
>

--
Jean-Baptiste M. "JBQ" Queru
Software Engineer, Android Open-Source Project, Google.

Questions sent directly to me that have no reason for being private
will likely get ignored or forwarded to a public forum with no further
warning.

Magnus Bäck

unread,
Jan 11, 2011, 4:12:08 PM1/11/11
to android-...@googlegroups.com
On Tuesday, January 11, 2011 at 22:01 CET,
Neil Perry <npe...@gmail.com> wrote:

You probably interrupted your sync at a bad moment and resumed later,
or I'm mixing up the missing .git/HEAD error with something else.
Either way, deleting the directory for this git and syncing again
should resolve it:

rm -rf system/external/bouncycastle
repo sync platform/system/external/bouncycastle

--
Magnus B�ck Opinions are my own and do not necessarily
SW Configuration Manager represent the ones of my employer, etc.
Sony Ericsson

Neil Perry

unread,
Jan 11, 2011, 4:34:06 PM1/11/11
to Android Building
Didn't think about deleting the dir to force it to re-sync that .git
repo.

Thanks for the quick replies, saved me some bandwidth.

Magnus Bäck

unread,
Jan 11, 2011, 4:37:11 PM1/11/11
to android-...@googlegroups.com
On Tuesday, January 11, 2011 at 22:16 CET,
Jean-Baptiste Queru <j...@android.com> wrote:

[...]

> Note2: the contents of .repo/projects are mostly branch-agnostic. If
> you have e.g. a froyo client and you want a gingerbread client next to
> it, you can copy .repo/projects from your froyo client to the new
> gingerbread one between repo init and repo sync. There's even a
> project to share .repo/projects even further but that's not current
> yet.
>
> If bandwidth is really expensive, it might even make sense so keep a
> backup copy of .repo/projects.

Don't forget the --reference option to repo init (added a couple of
months ago); it allows you to reuse all Git objects available in another
local workspace created with "repo init --mirror". You still won't be
absolved from talking to the remote server over the network, but with a
reasonably up to date mirror (say, cron job every morning) you at least
only have to download what's new since the last sync of the mirror.

This allows us to setup a fully populated 300+ git workspace in
~5 minutes rather than in ~30 minutes.

(Follow-ups should perhaps be directed to repo-discuss, the Google group
dedicated to Repo and Gerrit.)

modyrater

unread,
Jan 11, 2011, 8:13:49 PM1/11/11
to android-...@googlegroups.com
I thought the repo just picked up where it left off but not sure

Jean-Baptiste Queru

unread,
Jan 12, 2011, 10:36:07 AM1/12/11
to android-...@googlegroups.com
There are situations where repo leaves itself in a state that it can't
recover from, including cases where it can't find the ref that the
manifest points to.

We're getting off-topic here, and people interested in improving the
way repo handles such situations can discuss that on repo-discuss.

Thanks,
JBQ

--

Shawn Embedded

unread,
Jul 18, 2014, 10:49:44 PM7/18/14
to android-...@googlegroups.com

Really works, save me alot of time.
Thank you.

在 2011年1月12日星期三UTC+8上午5时16分33秒,Jean-Baptiste Queru写道:
Reply all
Reply to author
Forward
0 new messages