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

Create a new commit from patches without using any worktree?

From
KLKlas Lindberg <klas.lindberg@gmail.com>
Date
Oct 27, 2010, 01:49 UTC
Message-ID
<AANLkTi=Xi13_0+bC-TVRP3uVDmGWVdM3a708=SSzCR88@mail.gmail.com>
Hello

Is there any way to record a new commit based on contents in a patch without going through a worktree? Of course the operation would have to fail if the patch does not apply cleanly. The problem is I find myself doing things like this:

put away current work on some branch A checkout some branch B that is only used for patching run git patch --check to see if patches apply cleanly. *reject* if not. apply otherwise. return to branch A.

I.e. the checkout of B is redundant because I'm anyway not going to try to resolve any conflicts.

I know I can do something similar to what I need with "git-fetch src:dst", except it's rather awkward if what you have is patches. I suspect there must be some way to mimic that fetch behaviour manually, and in a way that lets me choose exactly what to apply?

BR / Klas
Next: Jonathan Nieder
Message 1 of 5 in “Create a new commit from patches without using any worktree?”
  1. Klas LindbergOct 27, 2010
  2. Jonathan NiederOct 27, 2010
  3. Johannes SixtOct 27, 2010
  4. Bert WesargOct 27, 2010
  5. Klas LindbergOct 27, 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.