Thread (8 messages) flat view 8 messages, 6 authors, 2016-06-15

Re: rm and mv commands: should I use them?

From: Jeff King <hidden>
Date: 2016-06-15 22:44:02

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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help