DontPanic
DontPanic

Reputation: 2416

How to extract a project tree from a git archive

I'm new to git and trying to do what I thought would be trivial. I just want to extract the files from the downloaded archive.

I used git clone https://android.googlesource.com/kernel/common.git

I got a directory "common" with several subdirs including common/.git/objects/pack/*biglongname*.pack and a similarly named .idx file.

I've search all over for a simple command to extract the source files. I've tried git archive, git unpack-objects, git pull and a bunch of others with no joy.

What am I missing here? this just has to be simple.

Upvotes: 1

Views: 6417

Answers (3)

CharlesB
CharlesB

Reputation: 90436

This repository is a bit strange, since the HEAD has no files in it. You have to checkout one of the two real branches:

 git checkout android-3.0

or

 git checkout android-2.6.39

Upvotes: 1

Benjamin Bannier
Benjamin Bannier

Reputation: 58754

The development in this particular repository doesn't happen on the master branch (the default branch checked out after the clone). You can use gitk to visualize what happened in any branch, e.g. for the last year

$ gitk --all --since='last year'

There you will see lots of commits to e.g. the android-3.0 branch. To switch your clone to that branch do

$ git checkout android-3.0

Had you known this you could have specified the branch to checkout after the clone at clone time

$ git clone -b android-3.0 https://android.googlesource.com/kernel/common.git

Upvotes: 1

Abizern
Abizern

Reputation: 150705

If you just want the source, not the repository, just delete the entire .git subdirectory.

If you've cloned the repository and you have nothing but the .git folder, try creating a branch to checkout the code:

git checkout -b master origin/master

do this within the common directory.

I'm surprised that git archive didn't work for you. That is another way of extracting the source to a different place.

Upvotes: 1

Related Questions