Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git bundle single commit?

Tags:

git

I want to apply a patch including its commit message, how do I bundle a single commit and apply it?

Given example history:

0a8b835 intel_pmc_ipc: Add Intel Apollo Lake PMC IPC driver
0d44b41 tc1100-wmi: Delete an unnecessary check before the function call "kfree"
b8830a4 dell-laptop: Fix allocating & freeing SMI buffer page
2ec1e9e target: Bump core version to v5.0
  • Say I wanted to bundle 0d44b41 as 001.bundle, and apply it?
  • Say I wanted to bundle b8830a4-through-0d44b41 as 002.bundle, and apply it?

Note: I can already do this with patch files, but I want to also include the commit mes automatically.

I tried to follow the git-scm doc on bundle with this command, which fails as:

$ git bundle create 001.bundle 0d44b41^ 0d44b41 
fatal: Refusing to create empty bundle.
like image 379
ThorSummoner Avatar asked Oct 30 '25 14:10

ThorSummoner


1 Answers

I'm not sure why you want specifically to limit yourself to git bundle, but assuming you do want that, take note of this wording in the documentation:

git-rev-list-args

A list of arguments, acceptable to git rev-parse and git rev-list (and containing a named ref, see SPECIFYING REFERENCES below), that specifies the specific objects and references to transport. ...

SPECIFYING REFERENCES

git bundle will only package references that are shown by git show-ref: this includes heads, tags, and remote heads.

Now consider your command:

$ git bundle create 001.bundle 0d44b41^ 0d44b41

The create 001.bundle specifies the file to create. The remainder of your command-line, 0d44b41^ 0d44b41, are the git-rev-list-args. What reference (branch or tag name) did you use here?1


Note that git format-patch includes commit messages (and author), and using git am will apply the commit including the original message (and author, though you will be the committer unless you do some additional setup work).


1Rhetorical question, of course: you did not use any. I'm not sure why git bundle is so very insistent on one, since you can easily attach a reference to a raw SHA-1, make the bundle, then remove the reference again without disturbing the just-created bundle. That would allow you to do what you're attempting. Or, of course, if there is a name (branch or tag for instance) pointing to the single commit you want bundled, you can use that existing name directly.

like image 90
torek Avatar answered Nov 02 '25 03:11

torek