Getting a branch's time of creation
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.
Signature · 2 lines
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.
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
"jateeq" == jateeq <[email protected]> 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
Signature · 4 lines
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095 <[email protected]> <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
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
Signature · 2 lines
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.
Quoted 5 lines · jateeq
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?
[...]
Quoted 2 lines
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>
Signature · 3 lines
Jakub Narebski Poland ShadeHawk on #git