git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

Next: Junio C Hamano
Message 1 of 2 in “Is there a way to fetch commits that are detached”
  1. Allan CaffeeApr 24, 2012
  2. Junio C HamanoApr 24, 2012

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.