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

Re: Adding a new file as if it had existed

From
Jakub Narebski <jnareb@gmail.com>
Date
Dec 12, 2006, 12:36 UTC
Message-ID
<elm7ji$m6g$1@sea.gmane.org>
In-Reply-To
<7ac1e90c0612120205k38b2fc14jbfd8ea682406efb2@mail.gmail.com>
Bahadir Balban wrote:
Show 10 quoted lines
> When I initialise a git repository, I use a subset of files in the
> project and leave out irrelevant files for performance reasons. Then
> when I need to make changes to a file not yet in the repository, the
> file is treated as new, and if I reset the change or change branches
> the file is gone.
> 
> Is there a good way of adding new files to git as if they had existed
> from the initial commit (or even better, since a particular commit)?
> This way I would only track the new changes I made to an existing
> file.

Generally, it is not possible without rewriting history. In git (in any sane SCM) commits are atomic; there is no CVS-like bunch of per-file histories. You can use cg-admin-rewritehist from Cogito (alternate UI for git)... but as it was said somewhere else git is fast. And the rule of thumb: check first, then optimize.

-- 
Jakub Narebski
Warsaw, Poland
ShadeHawk on #git
Previous: Andreas Ericsson
Message 11 of 11 in “Adding a new file as if it had existed”
  1. Bahadir BalbanDec 12, 2006
  2. Junio C HamanoDec 12, 2006
  3. Bahadir BalbanDec 12, 2006
  4. Johannes SchindelinDec 12, 2006
  5. Andy ParkinsDec 12, 2006
  6. Andreas EricssonDec 12, 2006
  7. Junio C HamanoDec 12, 2006
  8. Andreas EricssonDec 13, 2006
  9. Johannes SchindelinDec 13, 2006
  10. Andreas EricssonDec 13, 2006
  11. Jakub NarebskiDec 12, 2006

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.