2

I'm trying to deploy a rails app via git, but my folder structure is a bit goofy b/c i created everything in an unnecessary folder like this:

MASTER
------ mysite
------------- app
------------- conf
------------- Gemfile
....

My git url looks like this:

git@subdomain.beanstalkapp.com:/mysite.git

How can i either clone a repository from inside the "mysite" folder, or how can i remove the "mysite folder" and move it's content into the master branch itself?

the Tin Man
  • 158,662
  • 42
  • 215
  • 303
Catfish
  • 18,876
  • 54
  • 209
  • 353

3 Answers3

4

Is your mysite folder the only thing on its parent folder? If yes, you can move everything inside mysite folder to its parent folder. From the parent directory do:

mv -rf mysite/* .
rm -rf mysite
git add .
git commit -am 'removing mysite folder'
git push origin master
João Daniel
  • 8,696
  • 11
  • 41
  • 65
2

If you do not have any hidden files (dotfiles like .gitignore), João Daniel's answer should be sufficient.

These commands should all cases I can think of (including moving dotfiles)

# Change dir into the root of the repo
cd ROOT_DIRECTORY_OF_YOUR_REPO

# Find all content directly under mysite, and execute
# git mv on them with the destination directory as the
# current directory
find mysite/ -mindepth 1 -maxdepth 1 -exec git mv {} . \;

# Commit the change
git commit
Tuxdude
  • 47,485
  • 15
  • 109
  • 110
0

Git probably is not ideal for this, but you can probably do it with sparseCheckout.

"Is there any way to clone a git repository's sub-directory only?" is a similar question with a good walkthrough of the steps.

Once you've cloned the sub-folder, you could delete the sparseCheckout configuration commit the root and then push back to master.

Community
  • 1
  • 1
d_ethier
  • 3,873
  • 24
  • 31