Git Reflog

Let’s understand the git reflog and git log 👀

  • keep track of commit history,
  • if you have done hard reset,
  • it keeps track of git commit — amend as well
$ git push origin main
// I got to know I had to take pull from main (which some how I missed)
// and without taking pull I pushed forcefully
$ git push origin main -f
// successfully pushed to main branch
+ aauuii1...789011 HEAD -> branchname (forced update)
$ git reflog show remotes/origin/branchname
$ git checkout -b branch_name
$ git reset --soft aauuii1
// yayy! Its done 😍

Moral of the story 🥇

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store