Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

git: mv command

i've read that the mv command is basically the same as

$ mv README.txt README
$ git rm README.txt
$ git add README

just to be sure, is it exactly the same if i do it this way:

$ git rm --cached README.txt
# [rename file using right click rename]
$ git add README
like image 500
Pacerier Avatar asked Apr 28 '11 04:04

Pacerier


2 Answers

No. the --cached param is recommended when what you want is unstage and remove paths (in this case, the README.txt) only from the index. Working tree files, whether modified or not, will be left alone.

A better approach, on this case that is renaming a file, is use the build-in mv command of git. So:

$ git mv README.txt README

would have the same effect as you first approach, but with less type.

Font: http://www.kernel.org/pub/software/scm/git/docs/git-rm.html

like image 80
Gabriel L. Oliveira Avatar answered Sep 28 '22 16:09

Gabriel L. Oliveira


See What's the purpose of git-mv?.

Yes, it's pretty much the same.

like image 33
JohnD Avatar answered Sep 28 '22 17:09

JohnD