As shown below in a project
git add .
git commit -m "all"
git push
The above will add everything to the master branch,
But I hope that all the files in the examples directory will be added to the gh-pages branch for easy demonstration
Do not want to create a git init
git push origin gh-pages
will push all project files to gh-pages
And I only want the gh-pages branch to have all the files in the examples folder under the project, other files are not needed
Is there any other good way? Please give me some advice from the git master! !
What I want is to submit all the files of the project to the main branch, and all the files under the project folder example to be submitted to the branch of gh-pages
滿天的星座2017-05-02 09:25:48
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:
git add dist && git commit -m "Initial dist subtree commit"
Step 3
Use subtree to push the dist directory to the gh-pages branch:
git subtree push --prefix dist origin gh-pages
In this example, replace dist with example.
伊谢尔伦2017-05-02 09:25:48
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
为情所困2017-05-02 09:25:48
git checkout gh-pages
git checkout master -- example
git push origin gh-pages