Stephen G
Stephen G

Reputation: 193

Move a file to a new folder, keeping Git history

I am looking to move a folder so that it resides in another folder.

Currently: /folder1, moved to /holder/folder1, for example.

What is the easiest way to do this both on my home machine (Mac) and git to ensure that all of the history of the files within that folder remain on github.

Sorry for the newb question. I have only a very basic working knowledge of git, and would like to keep this as simple as possible.

Thanks!

Upvotes: 13

Views: 7325

Answers (1)

Raghuram
Raghuram

Reputation: 52635

From git documentation,

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

In the first form, it renames , which must exist and be either a file, symlink or directory, to . 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.

Upvotes: 18

Related Questions