git怎么把分支里的一个文件夹的内容替换master,并保留提交记录?

需求是这样的,我想把博客部署到xxx.github.io 但是这个github只支持在master中放置静态页面,所以就想能不能在src分支中的一个文件夹下生成静态页面,并把这个文件夹推送到master,但是git不允许这样做,

我在src分支下执行了这段代码git subtree push --prefix=docs/.vuepress/dist master src
然后给我提示

fatal: 'master' does not appear to be a git repository
fatal: Could not read from remote repository.

所以不能在master上这么玩???

阅读 2.9k
1 个回答

git subtree 一般用来处理不同的 git repository,从你的需求来看,你并不需要 git subtree,因为你完全就是操作同一个 repository 的不同的分支,甚至你都不需要 src 分支,你只需要将静态页面的文件夹命名为 docs,然后在 repository 的 setting 中设置:
clipboard.png

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题