git - How to pull in changes from skeleton sub-repository into production super-repository -
i using aurelia skeleton contains various project setups different purposes, more of general question of how git discribed below.
i able merge in updates published in github skeleton repository project working on. how that?
at moment initialized new local repository in skeleton-typescript project (which using) , connected private remote repo push changes. setup, polluting parent repository (remote pointing aurelia-skeleton on github) project-specific changes.
it perfect have kind of one-way tracking going aurelia-skeleton remote repository used pull changes in.
as second step, interesting how create pull request such setup. in case, use changes made in sub-repository merged fork of aurelia remote...
my usual workflow create dedicated branch track upstream project. can cherry pick want onto branch , create pull request without muddying template project specifics.
first thing, go ahead , fork aurelia/skeleton-navigation
can issue pull request through github's gui.
clone fork of project remote named upstream
in new folder called skeleton-typescript
git clone -o upstream git@github.com:your_github_username/skeleton-navigation.git skeleton-typescript cd skeleton-typescript
rename master branch.
git branch -m asmaster
create new repository skeleton-typescript
tip: can right command line using github's api curl
curl --data '{"name":"skeleton-typescript"}' -u your_github_username https://api.github.com/user/repos
add remote.
git remote add origin git@github.com:your_github_username/skeleton-typescript.git
split repo subtree (see source code man page) contain new tree commit history of files in prefix
directory.
git subtree split --prefix=skeleton-typescript
this print out single commit id head
of subtree.
539d913a8cf9b34b644273b5cdb480359553247c
create master branch commit.
git checkout -b master 539d913a8cf9b34b644273b5cdb480359553247c
push , track new repo.
git push -u origin master
backporting
commit work on skeleton-typescript
echo "notable contribution" >> file.txt git add . git commit -m "backport test commit" git push origin master
checkout upstream super-project branch, , cherry-pick subtree commits.
git checkout asmaster git cherry-pick -x --strategy=subtree master git push upstream asmaster:master
now can issue pull request upstream fork your_github_username/skeleton-navigation:master
branch aurelia/skeleton-navigation:master
branch.
updating
now there's going updates no doubt upstream's upstream (aurelia/skeleton-navigation:master
) include updates subtree's skeleton-typescript
folder.
add remote track original project.
git remote add upupstream git@github.com:aurelia/skeleton-navigation.git
note have 3 remotes in local repository.
git remote -v
origin git@github.com:your_github_username/skeleton-typescript.git (fetch) origin git@github.com:your_github_username/skeleton-typescript.git (push) upstream git@github.com:your_github_username/skeleton-navigation.git (fetch) upstream git@github.com:your_github_username/skeleton-navigation.git (push) upupstream git@github.com:aurelia/skeleton-navigation.git (fetch) upupstream git@github.com:aurelia/skeleton-navigation.git (push)
pull down updates.
git checkout asmaster git pull upupstream master
split off subtree again , grab head commit.
git subtree split --prefix=skeleton-typescript
095c0c9f7ed06726e9413030eca4050a969ad0af
switch subproject.
git checkout master
if have never backported changes, notable attribute of git subtree split
you'll have exact same hash commit history, can fast forward merges without rewriting history. the docs:
repeated splits of same history guaranteed identical (i.e. produce same commit ids). because of this, if add new commits , re-split, new commits attached commits on top of history generated last time, git merge , friends work expected.
git merge 095c0c9f7ed06726e9413030eca4050a969ad0af
however, if have backported cherry-picked updates, or other changes subtree history, you'll want rebase changes, otherwise you'll have duplicate commits.
git rebase 095c0c9f7ed06726e9413030eca4050a969ad0af
Comments
Post a Comment