Search code examples
gitgithubdirectory-structure

Move folder retrospectively in Git


I forked a repository which had a strange directory structure which I fixed as follows:

Before:

/core/src/com/example/core/Core.java

/simulation/src/com/example/simulation/Main.java

After:

/src/com/example/core/Core.java

/src/com/example/simulation/Main.java

When I moved these directories around, I was completely new to Git and simply did a git rm on the old ones and a git add to the new ones.

I have since made many changes to the files and I would like to send a pull request to the original repository for the new structure and content.

How can I tell Git to retrospectively move (mv) the files so that it is obvious where the files came from?


Solution

  • A git mv filex is the exact same as git rm filex followed by git add new\location\filex.

    There is no reason you would need to retrospectively change it.

    Here is some more info on it