How to direct git ignored folder to subtree branch?

I have a yoman angular application and by default the dist folder is ignored. So when I try to do this: git subtree push --prefix dist origin gh-pages it fails because it is ignored. I do not want to push the dist folder to the main branch, I only want to insert it into the gh-pages branch.

How can i achieve this?

+5
source share
3 answers

I ended up writing a script for this. It creates a temporary commit with an updated .gitignore file with deleted lines containing gh-pages .

After you click commit, it is discarded. An if statement exists, so you don't accidentally lose your job.

 STATUS="$(git status)" if [[ $STATUS == *"nothing to commit, working directory clean"* ]] then sed -i "" '/gh-pages/d' ./.gitignore git add . git commit -m "Edit .gitignore to publish" git push origin `git subtree split --prefix gh-pages master`:gh-pages --force git reset HEAD~ git checkout .gitignore else echo "Need clean working directory to publish" fi 
+2
source

Your answer here: https://gist.github.com/chrisjacob/825950

The link above describes how to push your files to the wizard, except for the dist folder; then you just go to your dist folder and, there, you click directly on the gh-pages branch.

Your question will achieve the perfect configuration, but I personally prefer to use the traditional "remove dist from .gitignore" and run the git subtree command "git subtree push -prefix dist origin gh-pages".

Now you make a decision!

0
source

Or you update the .gitignore file in the desired branch (preferred solution). Or push --force to force the upgrade.

-1
source

Source: https://habr.com/ru/post/1204134/


All Articles