git and the loss of revision numbers

David Wolfskill david at catwhisker.org
Tue Dec 29 01:06:34 UTC 2020


On Mon, Dec 28, 2020 at 04:56:39PM -0800, John-Mark Gurney wrote:
> monochrome wrote this message on Mon, Dec 28, 2020 at 19:38 -0500:
> > what would be the git command for reverting source to a previous version 
> > using these numbers? for example, with svn and old numbers:
> > svnlite update -r367627 /usr/src
> > 
> > this is needed often when it blows up for someone tracking current
> 
> Get the hash from a commit number:
> $git rev-list --reverse HEAD | tail -n +255241 | head -n 1
> 3cc0c0d66a065554459bd2f9b4f80cc07426464a
> 
> so:
> git checkout $(git rev-list --reverse HEAD | tail -n +255240 | head -n 1)
> ....

Or save a process:

git rev-list --reverse HEAD | awk 'NR == 255241 {print; exit 0}'
3cc0c0d66a065554459bd2f9b4f80cc07426464a

(And thus:
git checkout $(git rev-list --reverse HEAD | awk 'NR == 255241 {print; exit 0}')

Could also pass the number to awk via the "-v var=value" command-line.)

Peace,
david
-- 
David H. Wolfskill                              david at catwhisker.org
While Trump successfully conned a lot of people for a while, in the
end he's just a failure throwing a temper tantrum because he lost.

See https://www.catwhisker.org/~david/publickey.gpg for my public key.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 618 bytes
Desc: not available
URL: <http://lists.freebsd.org/pipermail/freebsd-current/attachments/20201228/7df45f0b/attachment.sig>


More information about the freebsd-current mailing list