【问题标题】:git-ftp just the contents of a directorygit-ftp 只是一个目录的内容
【发布时间】:2017-09-26 12:11:55
【问题描述】:

我正在尝试 git-ftp 只是特定目录的内容。为了清楚起见,我将描述我的确切问题,以防有其他修复:

我有一个 Jekyll 生成的静态站点,我正在尝试使用 git-ftp 将其上传到我的博客子域。我正在使用 --syncroot 标志仅 git-ftp 我的 _site 目录,但它正在上传目录本身(实际上是预期的行为)。但是现在当我访问我的博客 url 时,我并没有进入索引页面,我得到一个文件和目录列表 - 其中一个是 _site,然后当我点击那个链接时,我会进入我的页面。

因此,如果我可以仅将 _site 的内容上传到我网站的根目录,那就太好了,或者如果您对如何解决此问题有任何想法,我们将非常欢迎。

【问题讨论】:

  • git config git-ftp.syncroot _site/(以“/”结尾)应该可以解决问题。
  • 谢谢@marcanuy - 但对我没用,虽然我只用--dry-run 标志运行它,所以我不是100% 确定,但它看起来不像它正在运行工作。

标签: ftp jekyll git-ftp


【解决方案1】:

如何将_site 的内容复制到 git 存储库之外的文件夹中,例如publish 文件夹,然后使用 bash 脚本通过 git ftp 推送其内容?

date=`date +%Y-%m-%d-%H-%M-%S` #timestamp the commit below  
bundle exec jekyll build #update your _site directory  

cp -r _site/* ../publish/. #copy files from the _site to the publish folder  
cd ~/path/to/publish #cd into the publish folder  
git add .  
git commit -m "Deploy timestamp: $date" #add everything new and commit with a timestamp to the publish git repo 

git ftp catchup
git ftp push

【讨论】:

    【解决方案2】:

    所以我无法找到一种方法来仅上传 _site 目录的内容,但我确实提出了一个适合我需要的解决方案,如果他们遇到它可能会对其他人有所帮助这个问题。

    我所做的是忽略了我的项目中的 _site 目录,然后我进入了 _site 目录并初始化了一个新的 git repo。所以现在我直接跟踪我想要的目录,然后我可以使用 git-ftp 来 ftp 文件夹的内容,因为它只上传它初始化的目录的内容。这非常适合我的需要,因为无论如何,没有任何真正需要在我的项目中跟踪 _site 目录,因为它是一个生成的文件夹。

    期待有人发布比这更好的答案。

    【讨论】:

      猜你喜欢
      • 2012-09-06
      • 1970-01-01
      • 1970-01-01
      • 2015-01-08
      • 1970-01-01
      • 1970-01-01
      • 2017-07-05
      • 1970-01-01
      • 2014-04-15
      相关资源
      最近更新 更多