Incorporating Bootstrap into a git repo, using subtree merging -


i'm working on project we'd edit less files came twitter bootstrap. standard advice leave files untouched, make easier upgrade bootstrap. advice isn't working us; our code becoming fragile , hard maintain.

it seems should possible solve git subtree merging: edit bootstrap's less files have clear, maintainable code, use git's merge tools bring in new versions of bootstrap.

we've come plan using subtree merging. before put plan action, i'd feedback: are there significant drawbacks we've overlooked? there better/simpler approach?

approaches significant drawbacks

in simplest approach subtree merging, commits subtree (i.e., bootstrap) merged project's master branch. drawback bootstrap has many commits, our commits lost in noise. we'd keep commits off our master branch.

in theory, use git rebase -i squash bootstrap commits 1 commit, merge master. rebase -i does not work merges.

@sigi helpfully suggested use squash merges go bootstrap-upstream master. grabbing initial version of bootstrap (v3.1.0) worked ok. when merged in next version (v3.1.1), on 100 merge conflicts. every bootstrap change between 3.1.0 , 3.1.1 flagged conflict. (our exact steps in this gist.)

the plan

our plan use branch, merge-from-bootstrap, pulling bootstrap commits our repository. when merging changes in to merge-from-bootstrap (either our changes on master, or bootstrap's changes), record merge. when merging out from merge-from-bootstrap master, use git merge --squash merge not recorded.

our hope that:

  1. master stays managable, because bootstrap commits never become part of branch.
  2. git has information possible when merging in new version of bootstrap, since merge-from-bootstrap branch has full history of our changes , bootstrap team's changes.

proof of concept

in following steps, grab bootstrap v3.1.0, make changes, , upgrade v3.1.1. poc seems work (as did tests our real repo), i'd know if we're setting ourselves trouble down line.

start new repo, file readme.md (i.e., new repo github gives you).

# add bootstrap remote git remote add bootstrap https://github.com/twbs/bootstrap.git # fetch master branch; don't fetch tags git config remote.bootstrap.fetch +refs/heads/master:refs/remotes/bootstrap/master git config remote.bootstrap.tagopt --no-tags git fetch bootstrap  # start bootstrap v3.1.0 git checkout -b merge-from-bootstrap # sha commit tagged v3.1.0 bootstrap repo git merge -s ours --no-commit 1409cde7e800ca83fd761f87e5ad8f0d259e38d1 git read-tree -u --prefix=bootstrap/ 1409cde7e800ca83fd761f87e5ad8f0d259e38d1 git commit -am "bootstrap v3.1.0"  # merge bootstrap 3.1.0 master git checkout master git merge --squash merge-from-bootstrap git commit -am "merge bootstrap v3.1.0 master"  # make changes on master, have # merged sed -e 's/= space/= force-merge-conflict/g' -i '' bootstrap/.editorconfig git commit -am "force merge conflict" sed -e 's/"helvetica neue"/"comic sans"/g' -i '' bootstrap/less/variables.less  git commit -am "comic sans"  # ready upgrade new version of bootstrap git checkout merge-from-bootstrap git merge -s recursive -xtheirs master  # merge in bootstrap v3.1.1 bootstrap/master # merge-to-bootstrap. (sha v3.1.1 bootstrap repo) git merge -s recursive -x subtree=bootstrap --no-commit a365d8689c3f3cee7f1acf86b61270ecca8e106d  # fix merge conflict, do: git commit -am "merged in bootstrap v3.1.1"  # merge master git checkout master git merge --squash merge-from-bootstrap 

take approach described in pro git book:

on bootstrap branch, merge upstream changes:

$ git checkout bootstrap-upstream $ git pull 

then, on master branch, subtree merge bootstrap subtree with --squash option:

$ git checkout master $ git merge --squash -s subtree --no-commit bootstrap-upstream 

the key here use of subtree merge strategy, takes changes bootstrap wholesale , puts in place (sub-directory).

commit , write commit message:

$ git commit 

this avoid having history of bootstrap-upstream in master branch, , won't have use git rebase.


Comments

Popular posts from this blog

javascript - jquery or ashx not working -

opencv - DataType<cv::detail::deriv_type>::depth what is it used for -

python 3.x - Mapping specific letters onto a list of words -