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

Re: How to stage a tree with all changes?

From
Matthieu Moy <matthieu.moy@imag.fr>
Date
Jun 13, 2007, 16:47 UTC
Message-ID
<vpqy7inajib.fsf@bauges.imag.fr>
In-Reply-To
<861wgf964g.fsf@lola.quinscape.zz>
David Kastrup <dak@gnu.org> writes:
> Suppose I have a number of changes in a tree: additions, deletions,
> renames and so on.

At commit time, a rename is just an add+delete for git. It'll investigate renames with heuristics later, when needed.

> How do I stage and commit all of that?
Well, what I usually do is
  $ git status
(nicer with 
[status]
	color = auto
in ~/.gitconfig)
and then "confirm" one by one the things I actually want to commit.
Show 6 quoted lines
> git-commit -a
>
> omits new files.
>
> git-add .
> git-commit -a
The -a is not necessary if you just did "git add .".
> seemingly overlooks deletions.

In most cases, you'd have deleted the files with "rm", and you could have told git at that time, using "git rm" instead. Otherwise,

  $ git-ls-files -z | git-update-index --remove -z --stdin

will remove deleted files from the index after the fact. But I don't know any porcelain command to do that. Perhaps a "git rm -u" could be a nice dual for "git add -u"?

-- 
Matthieu
Previous: David KastrupNext: Jeff King
Message 2 of 3 in “How to stage a tree with all changes?”
  1. David KastrupJun 13, 2007
  2. Matthieu MoyJun 13, 2007
  3. Jeff KingJun 13, 2007

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.