2013-03-19 49 views
2

我想通过git部署一个rails应用程序,但我的文件夹结构有点愚蠢b/ci创建一切不必要的文件夹是这样的:Git需要从一个特定的文件夹克隆或删除顶级文件夹,但保留该文件夹的内容

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

我的git的URL看起来是这样的:

[email protected]:/mysite.git 

我无论怎样才能克隆从“mysite的”文件夹内的一个仓库,或者我怎么能删除“的mysite文件夹“并将其内容移入主分支本身?

+0

这不是一个Ruby或者Rails的问题。这完全是一个混帐问题。 – 2013-03-19 04:19:32

回答

3

您的mysite文件夹是其父文件夹中唯一的文件夹吗?如果是,您可以将mysite文件夹中的所有内容移动到其父文件夹。从父目录下执行:

mv -rf mysite/* . 
rm -rf mysite 
git add . 
git commit -am 'removing mysite folder' 
git push origin master 
+0

是的。感谢这个简单的解决方案 – Catfish 2013-03-19 00:17:40

+0

请,第一行是错误的。考虑: 'mv mysite/* .' – 2013-03-19 00:19:14

+1

'mv mysite/* .'不会移动像mysite/.gitignore这样的隐藏文件。 – Tuxdude 2013-03-19 04:51:55

2

如果您没有任何隐藏文件(像.gitignore一样的点文件),JoãoDaniel的答案应该足够了。

这些命令都应该情况下,我能想到的(包括移动点文件)

# 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 
相关问题