How do I reset my master to be a copy of rails master

I forked rails and then this is what I did.

> git clone git@github.com:nadal/rails.git
> cd rails
> git remote add upstream git://github.com/rails/rails.git
> git pull upstream master

Now git remote shows two items

> git remote
origin
upstream

I made a bunch of changes to master and comitted it. Then I created a bunch of branches to fix a few rails things. However when I rebase against master I also get changes I did to master.

I want to discard the changes I made to master.

Question:
Since I already committed some changes to my master, how do I reset my master to be exact copy of rails master. I want to discard the committs I made to my master.

  • Bitbucket different keys and accounts
  • Git remote branch workflow
  • How to add multiple projects into a Single repository in Bitbucket?
  • Git push fails within GNU screen
  • GITHUB is Pushing the changes with Old Credentials not with New Credentials
  • Remove Commit from Repository History
  • Checkout an older commit and create a new master branch?
  • I can't see the command prompt when using git bash in Windows
  • 2 Solutions collect form web for “How do I reset my master to be a copy of rails master”

    $ git checkout master
    $ git log  #find version you want, let's say it's 8cdb9
    $ git reset --hard 8cdb9     #master is now at version before you made changes
    $ git merge myFixBranch1   #assuming myFixBranch1 is a branch that you still want the changes from
    $ git pull upstream master    #if you want to update to latest rails code
    

    An easier way is to just visually inspect via

    gitk master 
    

    Once there, you can right click the node you want to go back to and select “reset master branch to here”. Choose “hard” to set your working folder to be the same as that commit as well. Close the window.

    git gui
    

    Now select merge from the menu, pick the local branch you want to merge.

    Hope this helps.

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