git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Santi Béjar" <santi@agolina.net>
To: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
Cc: git@vger.kernel.org
Subject: Re: understanding index
Date: Sat, 31 Jan 2009 13:09:49 +0100	[thread overview]
Message-ID: <adf1fd3d0901310409y28dc493ak358749e0c29154cc@mail.gmail.com> (raw)
In-Reply-To: <20090131111011.GA29748@ultras>

2009/1/31 Nicolas Sebrecht <nicolas.s-dev@laposte.net>:
>
> Hey list.
>
> I'm having some understanding trouble with git index. As I understand,
> 'git rm --cached' is not strictly the opposite of 'git add'. It's a
> little embarrassing in this particular case : what if you want to
> commit and did a wrong 'git add -u' command ?
>
> Here's a minimalist sample :
>
> % ls
> foo     bar
>
> [ hack, hack, hack on both files ]
>
> % git status
> [...]
>        modified: foo
>        modified: bar
> [...]
> % git add -u foo bar
>
> [ optional hack on foo ]
> [ damn, you realize you don't want to commit changes on foo at all ]
>

You omitted the help message of git status, where it says how to unstage:
# Changes to be committed:
#   (use "git reset HEAD <file>..." to unstage)

So to not commit foo at all:

git reset HEAD foo

HTH,
Santi
> % git rm --cached foo
> % git status
> [...]
>        deleted: foo
>        modified: bar
> [...]
>
> If committed as is, foo will be marked as deleted (in 'git log
> --name-status' at least, which is not wanted).
>
> How to retrieve the state before the wrong 'git add -u' command _and_
> keep the working tree as well (including last hacks) ? Is there any
> command which is the exact opposite of 'git add -u' ?
>
> Cheers,
>
> --
> Nicolas Sebrecht
>
> --
> To unsubscribe from this list: send the line "unsubscribe git" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>

  reply	other threads:[~2009-01-31 12:11 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-01-31 11:10 understanding index Nicolas Sebrecht
2009-01-31 12:09 ` Santi Béjar [this message]
2009-01-31 14:45   ` Alex Riesen
     [not found]   ` <20090131124022.GB29748@ultras>
2009-01-31 20:19     ` Nicolas Sebrecht
2009-01-31 20:57       ` Santi Béjar
     [not found]         ` <20090131210939.GD29748@ultras>
2009-01-31 22:07           ` Nicolas Sebrecht
2009-01-31 21:18       ` Björn Steinbrink

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=adf1fd3d0901310409y28dc493ak358749e0c29154cc@mail.gmail.com \
    --to=santi@agolina.net \
    --cc=git@vger.kernel.org \
    --cc=nicolas.s-dev@laposte.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).