Kurt Roeckx wrote: > On Sat, Feb 13, 2010 at 03:02:46PM -0600, Jonathan Nieder wrote:
>> Then while on the stable branch you use 'git cherry-pick H'. This >> produces a history like so: >> >> E -- F -- G --- H --- I --- ... [devel] >> / >> A -- B -- C -- D --- H' [stable] >> >> where H' introduces the same change as H did. > > Right, so it's called cherry picking. I guess I'm still to used > on how CVS works where this is just a merge. And the difference > with CVS seems to be that CVS doesn't know anymore that it came > from the devel branch after that. I don’t know CVS, but if I understand you correctly then git is like CVS in this respect (except for the name for the operation). Git doesn’t know any more that H' came from the devel branch. Humans might be able to tell from the commit message, and with effort git can figure it out by comparing patches, but that information is not explicitly stored anywhere. > A better example might be that both F and H where merged to the > stable branch, and that H fixes a bug introduced in G. > > I guess what I want to be able to see is each patch as applied to > the branch. If I'm currently at H', I want to see that F' is the > previous change in that branch. But I think it's showing me only > H now, and that G is the previous patch. The same goes for what > is the next patch obviously. I don’t understand. Part of my confusion is that what you are talking about is creating history, but gitk is mostly a tool for viewing history. So I am trying to imagine what series of commands created the history you are talking about and failing. The setup is presumably as before: test_commit() { : > "$1" git add "$1" git commit -m "$1" git tag "$1" } git init test-repo cd test-repo test_commit A git checkout -b devel for i in E F G H I J; do test_commit "$i"; done git checkout -b stable A for i in B C D; do test_commit "$i"; done I am on the stable branch, and I cherry-pick the bug fix F: git cherry-pick -x F Next I want to cherry-pick H. Why? H is a bug fix for G, so I guess I wanted G as well. git cherry-pick -x G git cherry-pick -x H And at this point, "gitk" and "git log" will show me a series of commits with subjects H, G, F, D, C, B, A, although the commits labelled H, G, and F on this branch have different commit IDs than the commits tagged H, G, and F, which were made on the devel branch. I guess this is where your wish comes in: maybe I wanted to cherry-pick the changes from G and H with a single commit? Let me back out the last two changes: git reset --hard HEAD^^ Now I apply the changes from G and H without making a commit: git cherry-pick --no-commit G git cherry-pick --no-commit H and make a commit git commit being sure to write a message that describes the combined change. Throughout, I might have a window open from running gitk --all & # or just gitk, or gitk devel, or whatever and hit Ctrl+F5 after each command to see its effect in gitk. > I think there used to be a way to only see the current branch > and not all branches that got merged in it? The thing is, F' and H' are not any different from the other commits in the stable branch. But suppose you want to see just those commits on the stable branch that do not have anything analogous in devel. (I have often wanted something like this.) The best way I know to do this is kind of clunky: gitk --left-right --cherry-pick devel...stable This will show the commits in devel but not in stable with a left- pointing marker and those stable but not in devel with a right- pointing marker. Note: a commit like the combined G+H described above would show up as a commit in stable but not in devel. > Maybe it should atleast show the branch name for each parent of > a commit? This sounds like a CVS-ism. Commits aren’t attached to any particular branch in git. Hope that helps, Jonathan -- To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org Archive: http://lists.debian.org/20100214091650.ga13...@progeny.tock