git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jeff King <peff@peff.net>
To: Jon Hancock <redstarling@gmail.com>
Cc: git@vger.kernel.org
Subject: Re: rm and mv commands: should I use them?
Date: Sun, 6 Jan 2008 03:08:25 -0500	[thread overview]
Message-ID: <20080106080825.GA9718@coredump.intra.peff.net> (raw)
In-Reply-To: <379EDA94-A67B-483A-BC5F-E961DD52AD0C@gmail.com>

On Sun, Jan 06, 2008 at 03:55:22PM +0800, Jon Hancock wrote:

> So, do I need to use git's mv and rm commands?  Can't I just rename, add, 
> and remove files using any means I like and then just ensure my "index" is 
> staged properly when I do a commit?

No, you don't need to use those commands. They really are just wrappers
that manipulate the working tree files and the index at the same time.
So instead of "git-mv a b" you can do "mv a b; git rm a; git add b".

> Additionally, is there a simple procedure with git to say: "I want to
> version exactly what is in my working tree.  If I removed something or
> added something, just handle it".  This is sort of what "git add ."
> does, but "git add" doesn't handling things I removed or moved,
> correct?

"git add ." will add the contents of any modified files to the index, as
well as add any untracked files (which may or may not be what you want).
It will not add removals. Try "git add -u" which updates all files that
git knows about (i.e., modifications and removals). You can also simply
use "git commit -a" which is the moral equivalent of "git add -u ; git
commit".

-Peff

  parent reply	other threads:[~2008-01-06  8:08 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-01-06  7:55 rm and mv commands: should I use them? Jon Hancock
2008-01-06  8:04 ` David Brown
2008-01-06  8:08 ` Brian Swetland
2008-01-06  8:08 ` Jeff King [this message]
2008-01-06 19:22 ` Linus Torvalds
2008-01-07  1:55   ` Jeff King
2008-01-07  2:05     ` Junio C Hamano
2008-01-07  3:06       ` Jeff King
2008-01-07 18:37         ` Robin Rosenberg
2008-01-07  3:05 ` Jay Soffian
2008-01-07  5:01   ` David Brown

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=20080106080825.GA9718@coredump.intra.peff.net \
    --to=peff@peff.net \
    --cc=git@vger.kernel.org \
    --cc=redstarling@gmail.com \
    /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).