git push branch pushes content under the selected folder
迷茫
迷茫 2017-05-02 09:23:48
0
3
683

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

in the examples directory
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

迷茫
迷茫

业精于勤,荒于嬉;行成于思,毁于随。

reply all(3)
滿天的星座

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.

伊谢尔伦

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

为情所困
git checkout gh-pages
git checkout master -- example
git push origin gh-pages
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template