How do I move my local, committed edits onto an _older_ version of my branch?
In Git, I have an external, central, golden repository with a bunch of tags:
golden repo:
1 - 2 (tag1) - 3 - 4 - 5 (tag2) - 6 - 7 - 8 (tag3) - 9
And I have a bunch of intermixed changesets in my clone of开发者_开发百科 that repo:
1 - 2 (tag1) - 3 - 4 - 5 (tag2) - *5.1* - 6 - 7 - *7.1* - 8 (tag3) - *8.1* - 9
I need to create a new repo that is a clone of the golden repo at tag2
with my edits on top:
1 - 2 (tag1) - 3 - 4 - 5 (tag2) - *5.1* - *7.1* - *8.1*
How can I move my edits ( as specified by *5.1*, *7.1*, *8.1*
) into a clone of the golden repository that has been reset --hard
to tag2
, but allow me to pull from the golden repo sometime in the future.
Clone your repo and create a new branch at tag2. you can than use git cherry-pick desiredCommit
to pull your individual commits into that branch.
You can still fetch goldenRepo with git fetch goldenRepo
.
1)
git clone yourRepo
...(tag2)- *5.1* - 6 - 7 - *7.1* - 8 (tag3) - *8.1* - 9<-origin/your_orig_branch
2)
git branch the_new_branch tag2
git checkout the_new_branch
...(tag2)- *5.1* - 6 - 7 -*7.1* - 8 (tag3) - *8.1* - 9<-origin/your_orig_branch
\
\ <-the_new_branch
3) Cherry pick each commit you want.
git cherryPick 5.1
...(tag2)-*5.1* - 6 - 7 - *7.1* - 8 (tag3) - *8.1* - 9<-origin/your_orig_branch
\
\ - *5.1* <-the_new_branch
4)
git fetch goldenRepo
/-- 6 - 7 - 8 (tag3) - 9<-remote/golden_branch
/
...(tag2) - *5.1* - 6 - 7 - *7.1* - 8 (tag3) - *8.1* - 9<-origin/your_orig_branch
\
\ - *5.1* - *7.1* - *8.1* <-the_new_branch
精彩评论