Possible Duplicate:
How to delete a 'git commit'
I am new to git and I encountered a situation which I need some help with.
I cloned a remote repository to my PC, and then opened a new branch named “meir”.
For practice purposes I first commited some changes I’ve made on a file. Afterwards, I changed the file the way I wanted it to be and commited again. Then I pushed my local branch to the remote repository.
The problem is that I have the first commit which was a test and I would not like it to be on the remote server. I thought about 2 possible ways to fix it:
- Remove the remote “meir” branch on the local and remote repository and start over.
- Remove only the first commit and then push the branch again to the server so it will also lose the first commit.
What commands do I need to run to achieve each of the options?
Thanks,
Meir
Generally speaking, you should not change commit history after you have pushed to public branch in a remote repository. It will cause pain to people who have pulled/cloned from the remote repository.
But if you really want to do it, you could use interactive rebase and forced push:
is setup the way you want the remote branch to be.
Another option is to remove the remote branch ‘meir’ with
git push origin :meir, resturcture your local repository withgit rebase -iand then push as normally.