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

Re: How to start well for a special git construction

From
Avery Pennarun <apenwarr@gmail.com>
Date
Mar 19, 2010, 20:48 UTC
Message-ID
<32541b131003191348q71a922d9nf9e295cbec6716a9@mail.gmail.com>
In-Reply-To
<e8be804e1003191330w70d9827cr1cfc1f46a5f45a2a@mail.gmail.com>

On Fri, Mar 19, 2010 at 4:30 PM, bruno le hyaric <bruno.lehyaric@gmail.com> wrote:

Show 6 quoted lines
> Thanks for your help.
> I've just created my empty new branch for delivery stuff... and
> effectively the branch is empty :-D
> Any idea on how I can add executable files in this empty branch from
> the master branch? Is that possible?
> (perhaps I'm using Git in a bad way)

There are fancy things you can do to create a branch containing only a single file without checking it out. It's a bit advanced, but it looks something like this:

    FILENAME=path/to/file
    BASENAME=$(basename $FILENAME)
    BLOBID=$(cat $FILENAME | git hash-object --stdin -w)
    TREEID=$(printf '100644 blob %s\t%s' $BLOBID $BASENAME | git mktree)
    COMMITID=$(echo Commit Message | git commit-tree $TREEID -p
refs/heads/release-branch)
    git update-ref refs/heads/release-branch $COMMITID

A more straightforward way to do it would be to clone your repository, and check out the release branch in your clone, then copy the file to it and commit as you normally would.

Have fun,
Avery
Previous: bruno le hyaric
Message 4 of 4 in “How to start well for a special git construction”
  1. bruno le hyaricMar 18, 2010
  2. Avery PennarunMar 18, 2010
  3. bruno le hyaricMar 19, 2010
  4. Avery PennarunMar 19, 2010

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.