Skip to content

Instantly share code, notes, and snippets.

@koistya

koistya/test.sh Secret

Last active November 11, 2017 14:44
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save koistya/0e2eab7ed6382db67a91ec462582e550 to your computer and use it in GitHub Desktop.
Git Subtree Experiment
#!/bin/bash -ex
rm -rf demo
mkdir demo
(cd demo && git init)
(cd demo && touch .gitignore)
(cd demo && git add .)
(cd demo && git commit -m 'Initial commit')
(cd demo && git remote add nodejs-api-starter https://github.com/kriasoft/nodejs-api-starter.git)
(cd demo && git fetch nodejs-api-starter)
(cd demo && git checkout -b nodejs-api-starter nodejs-api-starter/master)
(cd demo && git reset --hard f85245b8c6eb87c2b576034a3dd3c066c06ac726)
(cd demo && git checkout master)
(cd demo && git read-tree --prefix=api/ -u nodejs-api-starter)
(cd demo && git add .)
(cd demo && git commit -m "Merge 'kriasoft/nodejs-api-starter' into 'api/'")
(cd demo && touch api/foo.txt)
(cd demo && git add .)
(cd demo && git commit -m 'Add api/foo.txt')
(cd demo && touch api/boo.txt)
(cd demo && git checkout nodejs-api-starter)
(cd demo && git pull nodejs-api-starter)
(cd demo && git checkout master)
(cd demo && git merge -s subtree --no-commit nodejs-api-starter)
# fatal: refusing to merge unrelated histories
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment