tags:

views:

52

answers:

2

Hi,

i created a folder common with a bunch of source files and folders

But i want now to move the common folder into the include folder so it looks like include/common

i tried doing

1) git add include

2) git mv common/ include/

but it fails with this error

fatal: bad source, source=myrepo/common, destination=myrepo/include

3) i tried git mv common/ include/common but i get the same error

any idea how to achieve this?

+4  A: 
 git mv common include

should work.

From the git mv man page:

git mv [-f] [-n] [-k] <source> ... <destination directory>

In the second form, the last argument has to be an existing directory; the given sources will be moved into this directory.
The index is updated after successful completion, but the change must still be committed.

No "git add" should be done before the move.

VonC
+4  A: 

One of the nicest things about git is that you don't need to track file renames explicitly. Git will figure it out by comparing the contents of the files.

So, in your case, don't work so hard:

$ mkdir include
$ mv common include
$ git rm -r common
$ git add include/common

Running git status should show you something like this:

$ git status
# On branch master
# Changes to be committed:
#   (use "git reset HEAD <file>..." to unstage)
#
#   renamed:    common/file.txt -> include/common/file.txt
#
Andres Jaan Tack
good illustration if the "git way" ;) +1
VonC