* 'git log' numbering commits? @ 2012-04-12 7:54 Daniel Wagner 2012-04-12 8:41 ` Jeff King 0 siblings, 1 reply; 4+ messages in thread From: Daniel Wagner @ 2012-04-12 7:54 UTC (permalink / raw) To: git Hi, I have a stupid question I could not answer myself when reading the excellent documentation. My workflow involves a lot of "git rebase -i". For figuring out which commit id to use I do first a 'git log --oneline'. Then I do copy past the id to the 'git rebase -i'. The reason why I don't use relative id such as HEAD~4, because I keep miscounting the commits. So my question is there a magic option to have git log to enumerate the commits, e.g. 1: 2fcd2b3 network: Remove unused function 2: b376b2a session: Fix introspection for Change() 3: 15c9cd0 wifi: Refactor desctruction of network object 4: a9c699f network: Remove device pointer in network_remove() [...] cheers, daniel ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: 'git log' numbering commits? 2012-04-12 7:54 'git log' numbering commits? Daniel Wagner @ 2012-04-12 8:41 ` Jeff King 2012-04-12 9:15 ` Daniel Wagner 0 siblings, 1 reply; 4+ messages in thread From: Jeff King @ 2012-04-12 8:41 UTC (permalink / raw) To: Daniel Wagner; +Cc: git On Thu, Apr 12, 2012 at 09:54:12AM +0200, Daniel Wagner wrote: > My workflow involves a lot of "git rebase -i". For figuring out which > commit id to use I do first a 'git log --oneline'. Then I do copy past > the id to the 'git rebase -i'. The reason why I don't use relative > id such as HEAD~4, because I keep miscounting the commits. > > So my question is there a magic option to have git log to enumerate the > commits, e.g. > > 1: 2fcd2b3 network: Remove unused function > 2: b376b2a session: Fix introspection for Change() > 3: 15c9cd0 wifi: Refactor desctruction of network object > 4: a9c699f network: Remove device pointer in network_remove() No, there is no such feature. You can do this: git log --oneline | nl "-s: " but that will just give you the count of commits shown. If the history is not a single line of development, then those numbers will become meaningless quickly. Also note that there is an off-by-one in this scheme; HEAD~2 will be numbered as "3". If you wanted to simply decorate each commit with a more readable name, you could do this: git log --format='%H: %s' | git name-rev --stdin --name-only though for simplicity, you may find that you prefer to name only based on the current tip. You can do that like this: git log --format='%H: %s' | git name-rev --stdin --name-only \ --refs `git symbolic-ref HEAD` which yields output like: your-topic: network: Remove unused function your-topic~1: session: Fix introspection for Change() your-topic~2: wifi: Refactor desctruction of network object your-topic~3: network: Remove device pointer in network_remove() However, if you really just want this to make "rebase -i" easier, have you considered setting the upstream branch config for your branches? When I create a topic branch, I do: git checkout -b topic origin/master And then "git rebase -i @{upstream}" rebases everything up to my upstream branch (origin/master). That may be slightly more than I want, but it lets me see the whole series in the "rebase -i" sequencer. Recent versions of git even default to "@{upstream}", so you can just say "git rebase -i". How do you usually create your branches? What version of git are you using (the "@{upstream}" default is in v1.7.6 and later)? -Peff ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: 'git log' numbering commits? 2012-04-12 8:41 ` Jeff King @ 2012-04-12 9:15 ` Daniel Wagner 2012-04-12 18:14 ` Philippe Vaucher 0 siblings, 1 reply; 4+ messages in thread From: Daniel Wagner @ 2012-04-12 9:15 UTC (permalink / raw) To: Jeff King; +Cc: git Hi Jeff, On 12.04.2012 10:41, Jeff King wrote: > On Thu, Apr 12, 2012 at 09:54:12AM +0200, Daniel Wagner wrote: > >> My workflow involves a lot of "git rebase -i". For figuring out which >> commit id to use I do first a 'git log --oneline'. Then I do copy past >> the id to the 'git rebase -i'. The reason why I don't use relative >> id such as HEAD~4, because I keep miscounting the commits. >> >> So my question is there a magic option to have git log to enumerate the >> commits, e.g. >> >> 1: 2fcd2b3 network: Remove unused function >> 2: b376b2a session: Fix introspection for Change() >> 3: 15c9cd0 wifi: Refactor desctruction of network object >> 4: a9c699f network: Remove device pointer in network_remove() > > No, there is no such feature. You can do this: > > git log --oneline | nl "-s: " Obviously, I tend to forget the power of the pipes :) > but that will just give you the count of commits shown. If the history > is not a single line of development, then those numbers will become > meaningless quickly. Also note that there is an off-by-one in this > scheme; HEAD~2 will be numbered as "3". > > If you wanted to simply decorate each commit with a more readable name, > you could do this: > > git log --format='%H: %s' | > git name-rev --stdin --name-only > > though for simplicity, you may find that you prefer to name only based on > the current tip. You can do that like this: > > git log --format='%H: %s' | > git name-rev --stdin --name-only \ > --refs `git symbolic-ref HEAD` > > which yields output like: > > your-topic: network: Remove unused function > your-topic~1: session: Fix introspection for Change() > your-topic~2: wifi: Refactor desctruction of network object > your-topic~3: network: Remove device pointer in network_remove() Didn't know about name-ref. Very cool :) > However, if you really just want this to make "rebase -i" easier, have > you considered setting the upstream branch config for your branches? > When I create a topic branch, I do: Maybe I should have mentioned that on those project I am mostly working, we don't have branches (ConnMan, BlueZ, oFono). So we have a very simple history. > git checkout -b topic origin/master > > And then "git rebase -i @{upstream}" rebases everything up to my > upstream branch (origin/master). That may be slightly more than I want, > but it lets me see the whole series in the "rebase -i" sequencer. Recent > versions of git even default to "@{upstream}", so you can just say "git rebase > -i". The main reason I avoided branches is that I have several topics at the same time and having a single branch and maintaining them by hand was so far easier. > How do you usually create your branches? What version of git are you > using (the "@{upstream}" default is in v1.7.6 and later)? Normally I only have for big changes branches but for a few independent fixed I just use the master branch and fix the patches. But I see, I should over think my workflow here :) I am using git trunk :) I'll try the @{upstream} trick. Thanks a lot for this elaborate answer. cheers, daniel ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: 'git log' numbering commits? 2012-04-12 9:15 ` Daniel Wagner @ 2012-04-12 18:14 ` Philippe Vaucher 0 siblings, 0 replies; 4+ messages in thread From: Philippe Vaucher @ 2012-04-12 18:14 UTC (permalink / raw) To: Daniel Wagner; +Cc: Jeff King, git > I am using git trunk :) I'll try the @{upstream} trick. Not sure if it helps, but I use something that is somewhat easier to remember for me (specifying the upstream manualy): git rebase -i origin/master Philippe ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2012-04-12 18:14 UTC | newest] Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2012-04-12 7:54 'git log' numbering commits? Daniel Wagner 2012-04-12 8:41 ` Jeff King 2012-04-12 9:15 ` Daniel Wagner 2012-04-12 18:14 ` Philippe Vaucher
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.