1

Sorry if this question sounds dumb.

So, I am following Michael Hartl's Rails Tutorial.

Up to the end of chapter 8, everything was work fine.

But I have made some mistakes during chapter 9 that I cannot figure out.

So, I would like to go back to the commit I did at the end of chapter 8, to get everything working again and start over from here.

In other words, I want to erase everything that has been done since that last commit and (re)start fresh at the beginning of chapter 9.

According to the log, here is the commit I need to "retrieve" files from:

Computer:microblog TXC$ git log
commit dd0d9e82e802b18e5ba1000eff743445183bcc56
Author: thibaudclement <email@example.com>
Date:   Wed Jun 24 18:02:13 2015 -0700

    Finish log in/log out

I tried to git checkout from the current updating-users branch and git delete the branch, I tried to git pull from the remote, and I tried to git reset hard to the desired commit (as explained here: How to revert Git repository to a previous commit?), but I could not get my local files to look like the ones at the end of chapter 8.

How can I simply get on my local repository the files from the Finish log in/log out commit mentioned above?

Community
  • 1
  • 1
Thibaud Clement
  • 6,607
  • 10
  • 50
  • 103
  • So 'updating-users' is a dedicated branch for chapter 8? – Rahul Roy Jun 26 '15 at 03:57
  • Also, are you merging everything into master branch after each chapter? – Rahul Roy Jun 26 '15 at 03:59
  • 'updating-users' is a dedicated branch for chapter 9 (the one I made mistakes in). 'Finish log in/log out' is the last commit I made for chapter 8 (the one where everything was working fine). – Thibaud Clement Jun 26 '15 at 04:11
  • And yes, I am merging everything into master branch at the end of each chapter. I did so at the end of chapter 8, but did not do it yet for chapter 9 (fortunately), as it is not working properly. – Thibaud Clement Jun 26 '15 at 04:12
  • Cool! Thanks for quick response. I'm adding an answer, just go through it, and let me know, if it works for you. – Rahul Roy Jun 26 '15 at 04:15

1 Answers1

2

In case git reset --hard commit_id isn't working, try following:

  1. Discard any unstaged changes using:

    git reset --hard

  2. Checkout to master branch

    git checkout master

  3. Remove topic branch "updating-users"

    git branch -D updating-users

  4. Recreate a branch for chapter 9

    git checkout -b "name-of-the-branch"

I'm assuming that you're merging your topic branches into master branch, after each chapter.

filiprem
  • 6,721
  • 1
  • 29
  • 42
Rahul Roy
  • 473
  • 1
  • 6
  • 17