git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: git ready: daily git tips

From
Johannes Schindelin <johannes.schindelin@gmx.de>
Date
Feb 10, 2009, 10:19 UTC
Message-ID
<alpine.DEB.1.00.0902101117320.10279@pacific.mpi-cbg.de>
In-Reply-To
<slrngp1ljg.cnd.sitaramc@sitaramc.homelinux.net>
Hi,
On Tue, 10 Feb 2009, Sitaram Chamarty wrote:
Show 32 quoted lines
> On 2009-02-09, Nicolas Pitre <nico@cam.org> wrote:
> > On Sun, 8 Feb 2009, Nick Quaranto wrote:
> >> http://gitready.com
> >
> > Well done.
> >
> > One topic that IMHO you fail to cover, and which is being neglected 
> > almost everywhere else too, is the reflog.
> >
> > The reflog is really your safety net when working with git.  It records 
> > everything you do. So even if you screw up a rebase, perform the wrong 
> > merge, or any other kind of undesired operation, then you may always go 
> > back to a previous state.  Either you use -g with 'git log' to see all 
> > those recorded states, or even 'git reflog' without any argument to get 
> > a condensed list for HEAD.
> >
> > The <branch>@{<spec>} notation can be used anywhere a ref is normally 
> > required.  The special branch "HEAD" shows every state the HEAD pointer 
> > went through, including branch switches.  The <branch< part can be left 
> > out to mean "currently checked-out branch".
> >
> > One thing that I use all the time after a 'git pull' is 'git log @{1}..' 
> > where "@{1}" means the first previous tip of the current branch, so 
> > effectively showing me the log of what the pull brought in my branch.
> 
> Also, the @{now} notation to get a relative timestamp of the
> reflog is invaluable.  Seeing reflog lines annotated with
> '14 minutes ago' or '17 hours ago' or perhaps '4 days ago',
> really helps to focus on the commits you're looking for:
> 
>     git reflog show @{now}
>     # (the 'show' is not optional in this syntax)

Yes, I often use "git log -g --date=relative" to get a better understanding of my recent actions in that particular repository.

Also do not forget to advertise the new @{-<n>} notation for the n-th last branch you were on (to be part of 1.6.2 AFAIU). This comes in really handy when you juggle a dozen branches (and happen to commit to the wrong branch ;-)

Ciao, Dscho

Previous: Sitaram Chamarty
Message 5 of 5 in “git ready: daily git tips”
  1. Nick QuarantoFeb 8, 2009
  2. Steven NoonanFeb 8, 2009
  3. Nicolas PitreFeb 9, 2009
  4. Sitaram ChamartyFeb 10, 2009
  5. Johannes SchindelinFeb 10, 2009

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.