* Need some help with git rebase @ 2009-12-28 13:33 Sylvain RABOT 2009-12-30 22:24 ` Sylvain Rabot 0 siblings, 1 reply; 7+ messages in thread From: Sylvain RABOT @ 2009-12-28 13:33 UTC (permalink / raw) To: git Hello everybody, I'm trying to backport a feature branch which is based on the master branch into another branch also based on master but older : a--a--a--a--a--a--a--a--a feature / --x--x--x--x--x--x--x--x--x--x--x--x master \ o--o--o--o--o--o--o 12.72.1 This is what I would like : a--a--a--a--a--a--a--a--a feature / --x--x--x--x--x--x--x--x--x--x--x--x master \ o--o--o--o--o--o--o--a--a--a--a--a--a--a--a--a 12.72.1 And this is what I get with git rebase --onto 12.72.1 master feature o--o--o--o--o--o--o--a--a--a--a--a--a--a--a--a feature / --x--x--x--x--x--x--x--x--x--x--x--x master \ o--o--o--o--o--o--o--a--a--a--a--a--a--a--a--a 12.72.1 Can you exlain to me what I need to do to get what I expect. Best regards. -- Sylvain ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Need some help with git rebase 2009-12-28 13:33 Need some help with git rebase Sylvain RABOT @ 2009-12-30 22:24 ` Sylvain Rabot 2009-12-30 22:46 ` Wincent Colaiuta 2009-12-31 5:01 ` Tay Ray Chuan 0 siblings, 2 replies; 7+ messages in thread From: Sylvain Rabot @ 2009-12-30 22:24 UTC (permalink / raw) To: git So, I tried again "git rebase --onto 12.72.1 master feature". Situation : a--a--a--a--a--a--a--a--a feature / --x--x--x--x--x--x--x--x--x--x--x--x master \ o--o--o--o--o--o--o 12.72.1 Work flow : $ git checkout 12.72.1 $ git rebase --onto 12.72.1 master feature a lot of conflicts, resolving and git rebase --continue And then, at the end of the rebase, without me doing anything, feature branch is checked out and it seems that its HEAD has been reset to the new 12.72.1 HEAD. --x--x--x--x--x--x--x--x--x--x--x--x master \ o--o--o--o--o--o--o--a--a--a--a--a--a--a--a--a 12.72.1 feature Is that normal ? If it is, how do I do to avoid my feature branch to be reset at 12.72.1's HEAD ? Any enlightenment is very welcome. Regards. -- Sylvain Rabot <sylvain@abstraction.fr> ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Need some help with git rebase 2009-12-30 22:24 ` Sylvain Rabot @ 2009-12-30 22:46 ` Wincent Colaiuta 2009-12-31 9:02 ` Sylvain Rabot [not found] ` <7fce93be0912301502r77152c52sbccf762fb6c44610@mail.gmail.com> 2009-12-31 5:01 ` Tay Ray Chuan 1 sibling, 2 replies; 7+ messages in thread From: Wincent Colaiuta @ 2009-12-30 22:46 UTC (permalink / raw) To: sylvain; +Cc: git El 30/12/2009, a las 23:24, Sylvain Rabot escribió: > So, > > I tried again "git rebase --onto 12.72.1 master feature". > > Situation : > > a--a--a--a--a--a--a--a--a feature > / > --x--x--x--x--x--x--x--x--x--x--x--x master > \ > o--o--o--o--o--o--o 12.72.1 > > > Work flow : > > $ git checkout 12.72.1 > $ git rebase --onto 12.72.1 master feature > > a lot of conflicts, resolving and git rebase --continue > > And then, at the end of the rebase, without me doing anything, feature > branch is checked out and it seems that its HEAD has been reset to the > new 12.72.1 HEAD. > > --x--x--x--x--x--x--x--x--x--x--x--x master > \ > o--o--o--o--o--o--o--a--a--a--a--a--a--a--a--a 12.72.1 feature > > Is that normal ? If it is, how do I do to avoid my feature branch to > be > reset at 12.72.1's HEAD ? > > Any enlightenment is very welcome. Look at the "git-rebase" man page, particularly the order of the arguments, what they mean, and the usage examples of "--onto": $ git rebase --onto 12.72.1 master feature Means, "replay these changes on top of 12.72.1", where "these changes" refers to commits on branch "feature" with upstream "master", which is what "git rebase" did for you. If you actually want the "feature" branch to continue pointing at the old feature branch rather than your newly rebased one, you could just look up the old SHA1 for it and update it with: $ git branch -f feature abcd1234 Where "abcd1234" is the hash of the old "feature" HEAD. But I don't really know why you'd want to do that. The purpose of "git rebase" isn't to copy or cherry-pick commits from one branch onto another, but to actually _move_ (or transplant, or replay, if you prefer) those commits. Maybe I misunderstood your intentions though. Cheers, Wincent ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Need some help with git rebase 2009-12-30 22:46 ` Wincent Colaiuta @ 2009-12-31 9:02 ` Sylvain Rabot 2009-12-31 9:32 ` Peter Baumann [not found] ` <7fce93be0912301502r77152c52sbccf762fb6c44610@mail.gmail.com> 1 sibling, 1 reply; 7+ messages in thread From: Sylvain Rabot @ 2009-12-31 9:02 UTC (permalink / raw) To: git On Wed, Dec 30, 2009 at 23:46, Wincent Colaiuta <win@wincent.com> wrote: > > Look at the "git-rebase" man page, particularly the order of the arguments, what they mean, and the usage examples of "--onto": > > $ git rebase --onto 12.72.1 master feature > > Means, "replay these changes on top of 12.72.1", where "these changes" refers to commits on branch "feature" with upstream "master", which is what "git rebase" did for you. > > If you actually want the "feature" branch to continue pointing at the old feature branch rather than your newly rebased one, you could just look up the old SHA1 for it and update it with: > > $ git branch -f feature abcd1234 > > Where "abcd1234" is the hash of the old "feature" HEAD. > > But I don't really know why you'd want to do that. The purpose of "git rebase" isn't to copy or cherry-pick commits from one branch onto another, but to actually _move_ (or transplant, or replay, if you prefer) those commits. > > Maybe I misunderstood your intentions though. > > Cheers, > Wincent > In fact I want to backport the commits of the feature branch into 12.72.1. I used git rebase because the drawings of the man page looked like that I wanted to do and it does except for the part it resets the head of my feature branch. But the good behavior would be to cherry pick each commit of the feature branch and apply them into 12.72.1, right ? Thanks for your answer. Regards. -- Sylvain ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Need some help with git rebase 2009-12-31 9:02 ` Sylvain Rabot @ 2009-12-31 9:32 ` Peter Baumann 0 siblings, 0 replies; 7+ messages in thread From: Peter Baumann @ 2009-12-31 9:32 UTC (permalink / raw) To: Sylvain Rabot; +Cc: git On Thu, Dec 31, 2009 at 10:02:12AM +0100, Sylvain Rabot wrote: > On Wed, Dec 30, 2009 at 23:46, Wincent Colaiuta <win@wincent.com> wrote: > > > > Look at the "git-rebase" man page, particularly the order of the arguments, what they mean, and the usage examples of "--onto": > > > > $ git rebase --onto 12.72.1 master feature > > > > Means, "replay these changes on top of 12.72.1", where "these changes" refers to commits on branch "feature" with upstream "master", which is what "git rebase" did for you. > > > > If you actually want the "feature" branch to continue pointing at the old feature branch rather than your newly rebased one, you could just look up the old SHA1 for it and update it with: > > > > $ git branch -f feature abcd1234 > > > > Where "abcd1234" is the hash of the old "feature" HEAD. > > > > But I don't really know why you'd want to do that. The purpose of "git rebase" isn't to copy or cherry-pick commits from one branch onto another, but to actually _move_ (or transplant, or replay, if you prefer) those commits. > > > > Maybe I misunderstood your intentions though. > > > > Cheers, > > Wincent > > > > In fact I want to backport the commits of the feature branch into 12.72.1. > I used git rebase because the drawings of the man page looked like > that I wanted to do and it does except for the part it resets the head > of my feature branch. > > But the good behavior would be to cherry pick each commit of the > feature branch and apply them into 12.72.1, right ? > $ git checkout -b rebased_feature feature $ git rebase --onto 12.72.1 master rebased_feature will create a temporary branch named "rebased_feature" pointing to the same commit as the branch "feature". In fact, this will rebase the commits on the feature branch not reachable from master onto your 12.72.1 branch *and* won't reset the feature branch. Instead the temporary branch named "rebased_feature" will be rebased ontop of 12.72.1. I would still prefere the rebase over doing multiple cherry picks. -Peter ^ permalink raw reply [flat|nested] 7+ messages in thread
[parent not found: <7fce93be0912301502r77152c52sbccf762fb6c44610@mail.gmail.com>]
* Re: Need some help with git rebase [not found] ` <7fce93be0912301502r77152c52sbccf762fb6c44610@mail.gmail.com> @ 2009-12-31 11:06 ` Wincent Colaiuta 0 siblings, 0 replies; 7+ messages in thread From: Wincent Colaiuta @ 2009-12-31 11:06 UTC (permalink / raw) To: Sylvain Rabot; +Cc: git El 31/12/2009, a las 00:02, Sylvain Rabot escribió: > In fact I want to backport the commits of the feature branch into > 12.72.1. > > I used git rebase because the drawings of the man page looked like > that I > wanted to do and it does except for the part it resets the head of my > feature branch. > > But as you said the good behavior would be to cherry pick each > commit of the > feature branch and apply them into 12.72.1, right ? Well rebasing is just a convenient way of cherry-picking a bunch of commits, so it's probably the right tool for the job. But as you've seen, it has the effect of "moving" or "transplanting" the feature branch (replacing the old feature HEAD). If you really want the original feature branch HEAD to continue existing after the rebase you'll need to take some specific action to preserve it beforehand (creating a temporary branch before doing the rebase like Peter Baumann suggested) or restore it afterwards (using "git branch" like I suggested). But before you actually do that, I'd make sure that you actually have a valid reason for keeping that branch around. Maybe wanting to "backport" those commits onto various different branches might be a valid reason. But it's worth thinking through because Git gives you various tools for supporting different workflows (merging, rebasing, cherry-picking) and they each have their use cases. Cheers, Wincent ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Need some help with git rebase 2009-12-30 22:24 ` Sylvain Rabot 2009-12-30 22:46 ` Wincent Colaiuta @ 2009-12-31 5:01 ` Tay Ray Chuan 1 sibling, 0 replies; 7+ messages in thread From: Tay Ray Chuan @ 2009-12-31 5:01 UTC (permalink / raw) To: sylvain; +Cc: git Hi, On Thu, Dec 31, 2009 at 6:24 AM, Sylvain Rabot <sylvain@abstraction.fr> wrote: > And then, at the end of the rebase, without me doing anything, feature > branch is checked out and it seems that its HEAD has been reset to the > new 12.72.1 HEAD. > > --x--x--x--x--x--x--x--x--x--x--x--x master > \ > o--o--o--o--o--o--o--a--a--a--a--a--a--a--a--a 12.72.1 feature > > Is that normal ? If it is, how do I do to avoid my feature branch to be > reset at 12.72.1's HEAD ? reading the manual, I think this is normal. According to the third paragraph of the description of git-rebase, the branch feature will be reset to 12.72.1. You can just rename the branch back to 12.72.1, and retrieve the old tip of feature by examining the reflog. -- Cheers, Ray Chuan ^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2009-12-31 11:13 UTC | newest] Thread overview: 7+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2009-12-28 13:33 Need some help with git rebase Sylvain RABOT 2009-12-30 22:24 ` Sylvain Rabot 2009-12-30 22:46 ` Wincent Colaiuta 2009-12-31 9:02 ` Sylvain Rabot 2009-12-31 9:32 ` Peter Baumann [not found] ` <7fce93be0912301502r77152c52sbccf762fb6c44610@mail.gmail.com> 2009-12-31 11:06 ` Wincent Colaiuta 2009-12-31 5:01 ` Tay Ray Chuan
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).