You can get a list of the commits that your current branch pointed at, from most recent to least recent, by running
git reflog [branch-name]
where [branch-name]
is the current branch name. So what you could do is run this command to look at the history of the branch, find the ID of the commit ([commit-id]
) it pointed at before you ran your reset
command, and then do
git reset [commit-id]
You might use the --hard
option if you want to discard any uncommitted changes in the working directory.
A possible shortcut for this is
git reset [branch-name]@{1}
which resets the branch to the last commit it pointed at before its current state. That will work if and only if the reset you want to undo is the last thing you did to the branch. If you've made any commits or other changes to the branch since then, this won't do the right thing, and that's why I suggested looking at the reflog.
You can also use things like
git reset '[branch-name]@{5 hours ago}'
if you have a good idea of when the branch last pointed at the thing you want it to point at.