accidentally rolled back to a previous commit in git

I am new to Git and not sure what I did wrong. I have bunch of branches along side master for example – filling-layout, data-upload, sign-in-out etc. I had moved on to a new branch, when I had to change something in my layout. So I thought it would be better to go back to filling-layout branch and make the changes there. So I typed in git checkout filling-layout and that erased a bunch of things that I had in the layout and its back to a previous version and all my changes disappeared. I thought I had committed filling-layout after all my changes and uploaded it to github and heroku.

  • Any idea how I can get it back?
  • Also can anyone explain why this could happen?
  • What are the best practices when you have to make a small change that
    could potentially go into the previously committed branch?
  • Is it better to make a new branch or you can checkout the existing
    branch to make the change.

  • Unable to deploy with rails and capistrano, “HEAD is not the same as origin/master”
  • Cloning a Partial Perforce Repo with git-p4
  • git-apply fails mysteriously, how do I troubleshoot/fix?
  • How to skip “Hit return to start merge resolution tool” and open mergetool automatically
  • Git: Needed a single revision error
  • How can I get git clone --recursive A B to use the the submodule repositories in A?
  • How to deal with promoted conflicting branches on jenkins
  • When running repo sync error: Exited sync due to fetch errors
  • git revert commit/push but keep changes
  • git bundle with git-svn
  • How can I see all the issues I'm watching on Github?
  • Difference between `git branch -f <branch_name> <hash>` and `git checkout <branch_name>; git reset --hard <hash>` under a clean working tree?
  • One Solution collect form web for “accidentally rolled back to a previous commit in git”

    Try checking out the previous branch.

    This might work

    git checkout -

    It will try to checkout the branch you were on before the current one (analogous to cd -).

    Once you have committed your changes in git it is very difficult to loose them. Checking out a branch will change the working tree to match what is in that branch, but switching back will restore the state of the working tree to that of the previous branch.

    Another way to find previous commits is by using git reflog. That will list what commits HEAD has been at, and using the hash you can checkout any of those.

    Git Baby is a git and github fan, let's start git clone.