thanks to git reflog
, this is pure magic!
mkdir gitfun
cd gitfun
git init
touch test
git add test
git commit -m "added test"
touch other_file
git add other_file
git commit --amend
#"but this is a mistake"
git reflog > some_temporary_reflog
cat some_temporary_reflog
git checkout <HEAD@{1}: commit (initial): added test>
# now in detached head
git cherry-pick <hash from HEAD@{0}: commit (amend): but this is a mistake> --no-commit
# still on detashed head but with unstaged changes from wrong ammend
git commit -m "new commit I wanted to do before"
# you can then reset a local branch to your current HEAD
git checkout -B master
Some documentation:
https://en.wikibooks.org/wiki/Git/Internal_structure#The_Reflog
The reflogs record changes that are not saved as part of the commit history—things like rebases, fast-forward merges, resets and the like. There is one reflog per branch. The reflog is not a public part of the repository, it is strictly specific to your local copy, and information is only kept in it for a limited time (2 weeks by default). It provides a safety net, allowing you to recover from mistakes like deleting or overwriting things you didn’t mean to.
https://www.atlassian.com/git/tutorials/refs-and-the-reflog/the-reflog
Share this recording
Link
Append ?t=30
to start the playback at 30s, ?t=3:20
to start the playback at 3m 20s.
Embed image link
Use snippets below to display a screenshot linking to this recording.
Useful in places where scripts are not allowed (e.g. in a project's README file).
HTML:
Markdown:
Embed the player
If you're embedding on your own page or on a site which permits script tags, you can use the full player widget:
Paste the above script tag where you want the player to be displayed on your page.
See embedding docs for additional options.
Download this recording
You can download this recording in asciicast v1 format, as a .json file.
DownloadReplay in terminal
You can replay the downloaded recording in your terminal using the
asciinema play
command:
asciinema play 31118.json
If you don't have asciinema CLI installed then see installation instructions.
Use with stand-alone player on your website
Download asciinema player from
the releases page
(you only need .js
and .css
file), then use it like this:
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="asciinema-player.css" />
</head>
<body>
<div id="player"></div>
<script src="asciinema-player.min.js"></script>
<script>
AsciinemaPlayer.create(
'/assets/31118.json',
document.getElementById('player'),
{ cols: 80, rows: 25 }
);
</script>
</body>
</html>
See asciinema player quick-start guide for full usage instructions.
Generate GIF from this recording
While this site doesn't provide GIF conversion at the moment, you can still do it yourself with the help of asciinema GIF generator utility - agg.
Once you have it installed, generate a GIF with the following command:
agg https://asciinema.org/a/31118 demo.gif
Or, if you already downloaded the recording file:
agg demo.cast demo.gif
Check agg --help
for all available options. You can change font
family and size, select color theme, adjust speed and more.
See agg manual for full usage instructions.