1

So I have a git repo in this structure:

app
    app_one
    app_two
    app_three

The git repo root is in app. What I want is the root to simply be a folder containing app_one, app_two, app_three.

app_one
app_two
app_three

But the caveat is I want to do this while maintaining the current history of the file. Aka when I push this change to github, I don't want everything to show it was updated 3 seconds ago.

Josh
  • 13
  • 2

1 Answers1

4

I want to do this while maintaining the current history of the file.

The easiest (and best IMO) way:

git mv app_one app_two app_three .
git commit

You will still have access to the entire history of changes for all files in every folder.

I don't want everything to show it was updated 3 seconds ago.

This would require entirely rewriting the commit history with git filter-branch or git rebase. These are both dangerous if there are other developers who are working on existing branches. Also, they take a lot more time and effort. The above solution will work just fine for more cases.

For information about viewing history information across file moves see this question.

Community
  • 1
  • 1
Code-Apprentice
  • 81,660
  • 23
  • 145
  • 268
  • I would encourage this method be used^. However, if you are a confident repo surgeon, [it can be done](http://stackoverflow.com/a/5446061/1695680) – ThorSummoner Aug 22 '16 at 22:14
  • In addition to this answer you might want to read about the concept of content history and how to view the history of a moved file [here](http://stackoverflow.com/questions/5743739/how-to-really-show-logs-of-renamed-files-with-git). – lucash Aug 22 '16 at 22:34
  • @lucash Thanks. Added that link to the answer proper. – Code-Apprentice Aug 22 '16 at 22:49