在一个项目中如下图
git add .
git commit -m "all"
git push
上面会把所有的添加到 master 分支上,
但我希望 吧 examples 的目录下的 所有文件 都 添加到 gh-pages 分支 ,以便好做 演示
不希望在 examples 目录下 建立一个 git init
git push origin gh-pages
会把项目所有的文件都推送到 gh-pages
而我只想 gh-pages 分支 只有项目下 examples 文件夹下所有的文件 ,其他文件不需要
有木有其他 好办法呢 ! 求 git 大神支招!!
我要的是 项目所有的文件提交到主分支 ,项目文件夹 example 下的所有文件 提交到 gh-pages
的分支下
Step 1
Remove the dist directory from the project's .gitignore file (yeoman ignores the dist directory by default)
Step 2
Add dist directory to subtree:
Step 3
Use subtree to push the dist directory to the gh-pages branch:
In this example, replace dist with example.
Use git push origin gh-pages
origin is the name of your remote warehouse,
gh-pages is the name of the branch you want to push