threads / discuss / 23048

Getting a branch's time of creation

Subject: Getting a branch's time of creation

## tl;dr

4 messages between Mar 17, 2010 and Mar 19, 2010.

replies: 3people: 3as markdown or json

jateeq· Mar 17, 2010, 14:45 UTC · lore
Hello,

I am trying to find the time at which a remote branch was created, so that I can use the '--since' option in git log to limit the commits to only ones that were created for that branch (read below to see why I can't use 'git log <branchnname>). So my question: does git remember the time at which a branch was created, and how can it be listed?

NOTE: Once I clone a repository that contains Branch1 (which will have its
own commits as well as commits from the master branch), I create Branch2 in
the clone to track Branch1. Branch1 will have commits before the cloning,
and Branch2 will have its own commits after the cloning, but I want to list
both. The way I am thinking of doing it is to list all commits for Branch2,
and then limit the commits to only ones that were created after Branch1 was
created.

If anyone has suggestions on doing this alternatively, feel free to pitch in. Thank you. Jawad.

-- 
View this message in context: http://old.nabble.com/Getting-a-branch%27s-time-of-creation-tp27933166p27933166.html
Sent from the git mailing list archive at Nabble.com.
Randal L. Schwartz· Mar 17, 2010, 16:32 UTC · re: jateeq · lore

Re: Getting a branch's time of creation

>>>>> "jateeq" == jateeq  <jawad_atiq@hotmail.com> writes:

jateeq> I am trying to find the time at which a remote branch was created, so jateeq> that I can use the '--since' option in git log to limit the commits to jateeq> only ones that were created for that branch (read below to see why I jateeq> can't use 'git log <branchnname>). So my question: does git remember jateeq> the time at which a branch was created, and how can it be listed?

You're probably looking for the commit at the common ancestor of a given branch (which is a point, not a line, remember) and a branch you're interested in, like maybe "master".

consider something like:
git log $(git merge-base origin/somebranch origin/master)..origin/master
-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Smalltalk/Perl/Unix consulting, Technical writing, Comedy, etc. etc.
See http://methodsandmessages.vox.com/ for Smalltalk and Seaside discussion
jateeq· Mar 17, 2010, 17:24 UTC · re: Randal L. Schwartz · lore

Re: Getting a branch's time of creation

Great, that works - it gives me the commit that Branch 1 was at at the time of cloning.

One concern however. If I clone the repository, create Branch 2 to track Branch 1, and in the mean while push changes to the master branch of the repository, the commit that this command gives me changes (to the last commit that was pushed). The repository I am cloning from is bare, so in order to make changes to the master, I clone it again, make changes to the master branch of the clone and push those back (of course, this clone also has Branch 1 as a remote branch, but I am not making changes to it). What is git doing? Why does it change the commit history of Branch 1 when I did not push changes to it?

Before pushing to master: $git log --oneline $(git merge-base origin/jateeq.2010-03-16.15-32 origin/master)..origin/master 610cfae added file.xml

After pushing to master: $git log --oneline $(git merge-base origin/jateeq.2010-03-16.15-32 origin/master)..origin/master 9070a4d removed fcc.xml

Thanks, Jawad

-- 
View this message in context: http://n2.nabble.com/Getting-a-branch-s-time-of-creation-tp4750687p4751743.html
Sent from the git mailing list archive at Nabble.com.
Jakub Narebski· Mar 19, 2010, 20:54 UTC · re: jateeq · lore

Re: Getting a branch's time of creation

jateeq <jawad_atiq@hotmail.com> writes:
Show 5 quoted lines
> I am trying to find the time at which a remote branch was created, so that I
> can use the '--since' option in git log to limit the commits to only ones
> that were created for that branch (read below to see why I can't use 'git
> log <branchnname>). So my question: does git remember the time at which a
> branch was created, and how can it be listed?
[...]
> If anyone has suggestions on doing this alternatively, feel free to pitch
> in. Thank you.

It looks like an XY problem to me: you are asking how to get about specific solution, instead of about how to solve a problem.

If you know what branch was remote branch created from, you can simply use

  $ git log <base>..<branch>
which translates into
  $ git log <branch> ^<base>

which means everything in <branch> that is not present in <base>. (Assuming that <branch> is the branch you are interested in, and <base> is the branch it was branched off).

<base> might be result of "git config --get branch.<branch>.merge" (if the upstream was correctly configured).

You can also get branching point with
  $ git merge-base --all <base> <branch>
-- 
Jakub Narebski
Poland
ShadeHawk on #git

← back to recent threads