Currently, in one of my branch, I have two commits commit old
and commit latest
. commit latest
was done after the commit old
. Now, I want to merge only commit latest
to the master. I don't want any changes the commit old
will do. How can I remove a particular selected commit from github? After reading other answers, I found that I cannot do directly from github. I need to first revert back the changes on my local branch and then make a push again? Its confusing me how can I only revert changes of a particular commit and still keep the changes of my latest commit and if I do that what I need to do after it?
I would really appreciate any help or link. I am new to git/github.
In git if you have a commit - its whole history is part of it. Therefore you cannot merge a single commit, as this implies you merge its whole history, too.
If you do not want the changes of a single commit in the past, the trick is adding another commit on top of the latest one, which is undoing whatever the unwanted commit did. - This can be done with git revert
.
There is also git rebase
which is very powerful. But please do not use it until you completely understood how git works. - Otherwise you can break things much too easily.