Is there a way to fetch commits that are detached
- From
Allan Caffee <allan.caffee@gmail.com>
- Date
- Apr 24, 2012, 21:49 UTC
- Message-ID
- <CA+jCPNcmcxQcSN_BNvigQa2uRiaw-c2PK5T-y1yacYNs6Ws4WA@mail.gmail.com>
First some context: I'm trying to use the pre-receive hook to run some tests on a Hudson server before accepting the updates to a branch. At the moment I'm trying to have the Hudson job clone the repository (using the "git" protocol) and checkout the new ref as a detached head e.g.
$ git clone $GIT_REPOSITORY repository $ cd repository $ git checkout $GIT_COMMIT
But the checkout fails, apparently because the commit object hasn't been pulled into the local repository. Only a pack file is present in the local repository's objects directory which presumably doesn't have the commit.
Is there a way to explicitly fetch whatever objects are necessary to checkout the commit?
Would I be better off using git-archive to tar up a copy of the source instead, or some other means of copying the codebase over for testing?
Thanks, Allan