简体   繁体   中英

What is the best way to maintain a subtree branch?

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.

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?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM