1

I accidentally did a git.init on a parent folder of my app (Rails project). I didn't realise until a long way into my development when I now wish to deploy to Heroku.

My folder structure is ~/project/project/app with git initialised in ~/project/app.

Heroku states:

"Heroku apps expect the app directory structure at the root of the repository. If your app is inside a subdirectory in your repository, it won’t run when pushed to Heroku."

So, I'm trying to undo this, without much success.

I tried moving all the folders of my app up a level, so from project/ I did the following command:

mv project/* project/.* .

This seemed to move a copy of everything up a level, into my ~/project folder, however, in terms of Git, only the still nested files (in ~/project/project/) are the branch specific files (as tested by switching branches and looking at both sets of files in my text editor).

I copied the files when my git branch was specified as the master branch. Does this mean I've only copied the "master branch" files. This is where my knowledge of git is limited.

Any help much appreciated.

** note, i have a copy of my folder or can re-clone from github.

Tamlyn R
  • 211
  • 3
  • 9
  • Did you try `git mv project ...` ? – Adashi Apr 15 '17 at 19:27
  • I didn't, thanks for the tip. I can't quite get it to work. Did you literally mean the three dots? If so, I get: fatal: bad source, source=project/.gitignore, destination=.../.project I also tried git mv project .. but that gave an error as it was out of the git directory. – Tamlyn R Apr 15 '17 at 21:16
  • And then tried this too: git mv -nf project/* . which gives error: fatal: cannot move directory over file, source=project/app, destination=app – Tamlyn R Apr 15 '17 at 21:22
  • Not sure I entirely follow you, but you can try `git mv ~/project/project/app/* ~/project/app` – Adashi Apr 15 '17 at 22:37

1 Answers1

0

If you don't have a problem to re-publish your repo (git push --force, meaning you will change the history of commits, and other will have to fetch and reset their local branches), you can refer to "How can I move a directory in a Git repo for all commits?".

Use git filter-branch in order to affect all commits of all branches:

git filter-branch --tree-filter \
  'test -d project/app && mv project/app . || echo "Nothing to do"' HEAD
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250