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

Re: git-add and index

From
Junio C Hamano <gitster@pobox.com>
Date
Mar 3, 2009, 08:00 UTC
Message-ID
<7vprgzf32j.fsf@gitster.siamese.dyndns.org>
In-Reply-To
<20090303072008.GB7478@b2j>
bill lam <cbill.lam@gmail.com> writes:
> I have 2 questions related to index
> 1. Is it safe to just git-add (without commit) for local changes made
>    before checkout or switch to another branch?

As long as the other branch does not touch the same path, it should be kept in the index during the branch switching.

"Is it safe" and "does it work like this" questions are easier to answer by a bit of experimenting in a toy repository these days ;-).

> 2. How to checkout the changes as recorded in index from git-add that
>    not yet commit to the working tree?

"git checkout -- path"? If you do not have a revision that can be referred to as path (iow the file you are trying to check out of the index is not e.g. "master"), you do not have to say -- and just "git checkout path" should suffice.

Previous: bill lam
Message 2 of 2 in “git-add and index”
  1. bill lamMar 3, 2009
  2. Junio C HamanoMar 3, 2009

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.