Hello list,
[ git v1.6.3.3 ]
imagine this:
--A--*--B (new)
/
*--X--*--Y (master)
Now I'd like to list only log messages for A..B (X..B would be okay too).
I know of
git log master..new
however then I need to remember that I branched new of master, and to be honest,
sometimes I forget.
So how do I:
git please-tell-me-the-branch-I-started-this-branch-from new
Thanks in advance,
Stefan
--
BOFH excuse #181:
Atilla the Hub
On Wed, Dec 16, 2009 at 3:16 AM, [off-list ref] wrote:
imagine this:
--A--*--B (new)
/
*--X--*--Y (master)
Now I'd like to list only log messages for A..B (X..B would be okay too).
I know of
git log master..new
however then I need to remember that I branched new of master, and to be honest,
sometimes I forget.
So how do I:
git please-tell-me-the-branch-I-started-this-branch-from new
In the above example, you technically did not create 'new' off of
'master', you created new starting at X. You may think of it in terms
of branching off of 'master', but
git branch new master
resolves 'master' to the commit it points at and creates 'new'
pointing at that commit. That's all that is recorded. But I believe
the info you are really interested in is where new started, rather
than the fact that it branched off master. Is that correct? If so,
just use new@{30.years.ago} (or any other sufficiently long period of
time):
git log new@{30.years.ago}..new
(You'll get a warning that 'new' hasn't existed for 30 years but it
doesn't hurt anything)
Hope that helps,
Elijah
On Wed, Dec 16, 2009 at 11:05:52AM -0700, Elijah Newren [off-list ref] wrote:
git log new@{30.years.ago}..new
(You'll get a warning that 'new' hasn't existed for 30 years but it
doesn't hurt anything)
That's the same as "git log new", if I'm not mistaken.
What Stefan wants to do is to let git log show the commits which are
only in the "new" branch, but I don't think there is an out-of-the-box
solution for that.
One solution I can think of is to iterate over each ref using "git
for-each-ref --format='%(refname)' 'refs/heads/*'", then run "git
merge-base $i new", run git rev-list $mb..new|wc -l and then you could
decide what is the first commit that does not belong to any other
branch. But that's just an idea, I don't have the motivation to script
it properly.
On Thu, Dec 17, 2009 at 12:26 AM, Miklos Vajna [off-list ref] wrote:
On Wed, Dec 16, 2009 at 11:05:52AM -0700, Elijah Newren [off-list ref] wrote:
quoted
git log new@{30.years.ago}..new
(You'll get a warning that 'new' hasn't existed for 30 years but it
doesn't hurt anything)
That's the same as "git log new", if I'm not mistaken.
What Stefan wants to do is to let git log show the commits which are
only in the "new" branch, but I don't think there is an out-of-the-box
solution for that.
Not out-of-the-box but this does exactly what you said, print all
commits only reachable from the "new" branch:
git log new --not $(git for-each-ref --format='%(refname)'
'refs/heads/*' | grep -v refs/heads/new)
For the original question, I think what makes most sense in this case
is asking for the commits since the upstream branch. Some time ago
there was a discussion about a syntax for the tracking branch and
there was even a patch:
Subject: [PATCH v2] Introduce <branch>@{upstream} as shortcut to the
tracked branch
Date: 2009-09-10 15:25:57 GMT
http://news.gmane.org/find-root.php?message_id=%3calpine.DEB.1.00.0909101724520.8306%40pacific.mpi%2dcbg.de%3e
but it's not in git.git.
HTH,
Santi
On Wed, Dec 16, 2009 at 4:26 PM, Miklos Vajna [off-list ref] wrote:
On Wed, Dec 16, 2009 at 11:05:52AM -0700, Elijah Newren [off-list ref] wrote:
quoted
git log new@{30.years.ago}..new
(You'll get a warning that 'new' hasn't existed for 30 years but it
doesn't hurt anything)
That's the same as "git log new", if I'm not mistaken.
Did you try it with a 'new' branch in your repository that started at
the beginning of history rather than at some commit? "git log new"
and "git log new@{30.years.ago}..new" are not the same for me with
git-1.6.5.5:
$ git init repo
$ cd repo
$ echo content> foo && git add foo && git commit -mone foo
$ echo more content >> foo && git commit -mtwo foo
$ git checkout -b new master~1
$ echo stuff >> foo && git commit -mthree foo
$ git log new@{30.years.ago}..new
warning: Log for 'new' only goes back to Wed, 16 Dec 2009 16:48:02 -0700.
commit 7df8bad7cc146875c59ab030da0d25555976e79c
Author: Elijah Newren [off-list ref]
Date: Wed Dec 16 16:48:07 2009 -0700
three
$ git log new
commit 7df8bad7cc146875c59ab030da0d25555976e79c
Author: Elijah Newren [off-list ref]
Date: Wed Dec 16 16:48:07 2009 -0700
three
commit b86eadcdb152877ade44bebf4b8742884949f29f
Author: Elijah Newren [off-list ref]
Date: Wed Dec 16 16:47:31 2009 -0700
one
What Stefan wants to do is to let git log show the commits which are
only in the "new" branch, but I don't think there is an out-of-the-box
solution for that.
Are you sure? I'm more inclined to believe he'd like to see all the
commits that have been added to the "new" branch since he created it
(which may be the same as what you say, but not necessarily). Of
course, neither my assumption or yours match what he actually asked
for (though I think what he asked for isn't possible and is merely an
means to the end he really wants).
Also, I think this does what you asked for (the commits in the "new"
branch but no other branch):
$ git log new $(git for-each-ref --format='%(refname)' 'refs/heads/*'
| grep -v '^refs/heads/new$' | sed -e s/^/^/)
On Wed, Dec 16, 2009 at 04:59:54PM -0700, Elijah Newren [off-list ref] wrote:
Did you try it with a 'new' branch in your repository that started at
the beginning of history rather than at some commit? "git log new"
and "git log new@{30.years.ago}..new" are not the same for me with
git-1.6.5.5:
$ git init repo
$ cd repo
$ echo content> foo && git add foo && git commit -mone foo
$ echo more content >> foo && git commit -mtwo foo
$ git checkout -b new master~1
$ echo stuff >> foo && git commit -mthree foo
$ git log new@{30.years.ago}..new
Aah, thanks. Then you can just avoid the warning using
git log $(git reflog show new|sed -n 's/ .*//;$ p')..new
Are you sure? I'm more inclined to believe he'd like to see all the
commits that have been added to the "new" branch since he created it
(which may be the same as what you say, but not necessarily). Of
course, neither my assumption or yours match what he actually asked
for (though I think what he asked for isn't possible and is merely an
means to the end he really wants).
No, I'm not sure about what he thought, but I hope he will clarify. :)
From: David Roden <hidden> Date: 2016-06-15 22:47:55
bd@bc-bd.org wrote:
imagine this:
--A--*--B (new)
/
*--X--*--Y (master)
Now I'd like to list only log messages for A..B (X..B would be okay too).
I know of
git log master..new
however then I need to remember that I branched new of master, and to be
honest, sometimes I forget.
So how do I:
git please-tell-me-the-branch-I-started-this-branch-from new
Thanks in advance,
I have had wonderful results using
git log new --not master
or
git log new ^master
This is using git 1.6.4.4 and this way of specifying commits is not
mentioned in the man page—it seems to work, though.
David
From: Stefan Völkel <hidden> Date: 2016-06-15 22:47:55
Hi,
git log $(git reflog show new|sed -n 's/ .*//;$ p')..new
I had trouble getting the above to work as a git alias (someething wrt
escaping I guess), however this:
gl = log --graph --pretty=oneline --abbrev-commit
bl = !sh -c 'git gl $0 --not $(git for-each-ref --format=%\\(refname\\)
refs/heads/* | grep -v refs/heads/$0)'
does exactly what I want:
# git reflog show new
76cacd3 new@{0}: commit: B
9638379 new@{1}: commit: A
7944f55 new@{2}: branch: Created from HEAD
# git gl
* 76cacd3 B
* 9638379 A
* 7944f55 Y
* b8e4a96 X
# git bl new
* 76cacd3 B
* 9638379 A
Thanks for the help,
Stefan
So how do I:
git please-tell-me-the-branch-I-started-this-branch-from new
You may also be interested in the git show-branch command. The output
may be unintuitive at first but once you grok it it's pretty useful...
especially if you have several branches.
Aside from the man page, here's a blog post the describes the output:
https://wincent.com/wiki/Understanding_the_output_of_%22git_show-branch%22
~ Pat