0

I have local repository setup with 2 branches master and sandbox. I made changes on sandbox: 1. Changes for the working version and, 2. Changes to get the version working on my Windows machine.

I committed the changes separately, first 1 then 2. I then merged the master branch with the sandbox branch.

Now because I wanted to ignore change set 2 (changes to get working on Windows), I created a .gitignore with the following content.

$ cat .gitignore

#changed for local
conn.php
.htaccess

I then pushed the master branch to the remote master on GitHub, but now looking at the last 2 commits they are local machine development envonment changes (2).

And, I created my .gitignore with notepad++ but it is not hidden and looks like a textfile.

So, I would like to undo the last 2 commits on the github remote repository.

tread
  • 10,133
  • 17
  • 95
  • 170

1 Answers1

1

You can use the reset --hard command but be warned that it will wipe out any uncommitted changes in your working copy. Find the sha1 of the commit you want your branch to point at (I.e. before the last 2 commits) then use:

git reset --hard abcdef1234

Where abcdef1234 is the sha1 of the commit you want to go back to. Afterwards you might have to force push your changes to the remote with:

git push -f origin sandbox

Or master, depending on which branch you are modifying

SDJMcHattie
  • 1,690
  • 1
  • 15
  • 21
  • note that if someone already pulled from that repository, he is not going to see the removal (at first) and then will either get merges (when pulling) or errors (when pushing) – sylvain.joyeux Apr 08 '13 at 07:06