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

Re: "git apply" can't add new files to repo ?

From
Carlos Martín Nieto <cmn@elego.de>
Date
Jul 15, 2011, 19:34 UTC
Message-ID
<1310758497.7308.20.camel@centaur.lab.cmartin.tk>
In-Reply-To
<CAAnh3_-ayozWnHR-ViJ3zjXQvPQA1kd9spGV_TEU=-kFzBytvw@mail.gmail.com>
On Fri, 2011-07-15 at 12:02 -0700, Yang wrote:
Show 12 quoted lines
> I created a patch by "git format-patch", and this patch includes some
> newly-added files.
> 
> when I got back to the original branch, and apply this patch, the new
> files appear, but they are not
> added to git repository, so I have to manually find all the new files
> and do "git add" for each of them.
> 
> 
> I guess there should have been a way to automatically do "git add" for
> all the new files in the patch,
> how could I do that?

git-apply is just a wrapper around the patch(1) utility. As you have created a patch for use in an email (as that's the point of using format-patch, so you have both the commit message and diff in one place), you should use git-am, which takes care of all the "magic". If you want to change what the patch does, you just need to use git commit --amend

Cheers,
   cmn
-- 
Carlos Martín Nieto        http://www.cmartin.tk

"¿Cómo voy a decir bobadas si soy mudo?" -- CACHAI
Previous: YangNext: Junio C Hamano
Message 2 of 6 in “"git apply" can't add new files to repo ?”
  1. YangJul 15, 2011
  2. Carlos Martín NietoJul 15, 2011
  3. Junio C HamanoJul 15, 2011
  4. Carlos Martín NietoJul 15, 2011
  5. Junio C HamanoJul 15, 2011
  6. YangJul 15, 2011

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.