Pergunta

I have a git repo and would like to create branch that only contains the contents of a sub-directory of Master.

Here's a visual representation of what I want:

Master Branch
 |__app
 | |__scripts
 | | |__partials
 | | | |__partial_1.js
 | | | |__partial_2.js
 | | |__main.js
 | |__styles
 | | |__partials
 | | | |__base.scss
 | | | |__typography.scss
 | | |__main.scss
 | | |__main.css
 | |__index.html
 |__dist
 | |__scripts
 | | |__main.js
 | |__styles
 | | |__main.css
 | |__index.html
 |__.gitignore
 |__gulpfile.js

Deploy Branch
 |__scripts
 | |__main.js
 |__styles
 | |__main.css
 |__index.html

The purpose of this deploy branch is to maintain a version of the project that can be deployed from easily. That way I don't have to pull from a subdirectory of Master.

I was able to achieve the start of this with git subtree split --prefix=dist -b Deploy but I'm not sure if this was the right way to go about this, and if it was I have no idea how to now merge new changes to master/dist/ to deploy/.

The only info I could find about merging a subtree was about merging it back to master, not merging master changes to the subtree branch.

I'd really appreciate some help with this. Thanks


Workaround

My current workaround is to git branch -D Deploy and then git subtree split -P dist -b Deploy for each deployment.

Foi útil?

Solução

Alright I guess I can just run git subtree split -P dist -b deploy regardless of whether or not deploy already exists. Seems to work to me. Any reason not to do this?

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top