Last active
August 29, 2015 14:00
-
-
Save evan-dickinson/11407758 to your computer and use it in GitHub Desktop.
Merging Bootstrap with squash merges to master
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# An approach of incorporating Bootstrap into a git repo, | |
# using subtree merging. This approach does squash merges | |
# from bootstrap-upstream to master, and results in merge | |
# conflicts. | |
# | |
# This gist is part of this StackOverflow question | |
# http://stackoverflow.com/questions/23095230/incorporating-bootstrap-into-a-git-repo-using-subtree-merging | |
# Create the repo | |
git init . | |
touch README.md | |
git add --all | |
git commit -am "Initial version" | |
# Add bootstrap as a remote | |
git remote add bootstrap https://github.com/twbs/bootstrap.git | |
# Only fetch the 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 | |
# Make tags for the two bootstrap versions we need | |
git tag bootstrap-v3.1.0 1409cde7e800ca83fd761f87e5ad8f0d259e38d1 | |
git tag bootstrap-v3.1.1 a365d8689c3f3cee7f1acf86b61270ecca8e106d | |
git checkout -b bootstrap-upstream bootstrap/master | |
# Start with Bootstrap v3.1.0 | |
git checkout master | |
git read-tree -u --prefix=bootstrap/ bootstrap-v3.1.0 | |
git commit -am "Bootstrap v3.1.0" | |
# Make some changes on master, so that we have something to | |
# be merged | |
sed -e 's/= space/= force-merge-conflict/g' -i '' bootstrap/.editorconfig | |
git commit -am "Force a merge conflict" | |
sed -e 's/"Helvetica Neue"/"Comic Sans"/g' -i '' bootstrap/less/variables.less | |
git commit -am "Comic Sans" | |
# Merge Bootstrap v3.1.1 to master | |
git checkout master | |
# Doing a subtree merge does not work: The result is that most of the | |
# bootstrap files are deleted. Perhaps it's related to this problem? | |
# http://stackoverflow.com/questions/1306595/git-confused-when-merging-an-update-into-my-subtree?rq=1 | |
# | |
# git merge --squash -s subtree --no-commit bootstrap-v3.1.1 | |
# Instead, pass in the subtree argument to recursive merge, which explicitly | |
# tells git where we put bootstrap. | |
# | |
# Note: "bootstrap" cannot end in a slash. See | |
# http://git.661346.n2.nabble.com/Bug-Subtree-merge-seems-to-choke-on-trailing-slashes-td7570648.html | |
git merge --squash -s recursive -X subtree=bootstrap --no-commit bootstrap-v3.1.1 | |
# The big problem happens here: We get over 100 merge conflicts in the Bootstrap code. | |
# Every file that changed in Bootstrap has a merge conflict. | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment