Search code examples
gitgithubgit-svnmovemv

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

Solution

  • 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