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 exa开发者_如何学编程ct copy of rails master. I want to discard the committs I made to my 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.
精彩评论