I did a pull request but after that I made some commits to the project locally which ended polluting my pull request, I tried to remove it but without any luck.
I found some similar questions on StackOverflow but I can't apply what's in there. It's my first pull request on GitHub so it's kinda strange to me how all of this works.
The highlighted commit is the one I need to keep and remove all the other stuff. It becomes the fourth commit in the history because I make some merge stuff.
my git log
Can someone please explain what's going on and how to fix this problem?
Step-1: Make sure your working directory is clean ( commit or stash your current changes). Step-2: One can use the git-rebase command to easily make changes to one's history. After running the git rebase command you get the following in your $EDITOR: Step-3: Replace pick with drop to “drop” the commit.
To remove the last commit from git, you can simply run git reset --hard HEAD^ If you are removing multiple commits from the top, you can run git reset HEAD~2 to remove the last two commits. You can increase the number to remove even more commits.
If the file change is simple and the PR is still open, just go to your branch, modify the file back to the way it was originally and then commit and push your change. Your PR should be updated and the file will disappear if it exactly matches the target branch.
Simplest way, Just look for the log and have a count which commits and check out the commit-msg which you want to drop. Replace x with the count, I will show all the commit-msg, just delete the commit-msg which you want to remove.
People wouldn't like to see a wrong commit and a revert commit to undo changes of the wrong commit. This pollutes commit history.
Here is a simple way for removing the wrong commit instead of undoing changes with a revert commit.
git checkout my-pull-request-branch
git rebase -i HEAD~n
// where n
is the number of last commits you want to include in interactive rebase.
pick
with drop
for commits you want to discard.git push --force
You have several techniques to do it.
This post - read the part about the revert will explain in details what we want to do and how to do it.
Here is the most simple solution to your problem:
# Checkout the desired branch git checkout <branch> # Undo the desired commit git revert <commit> # Update the remote with the undo of the code git push origin <branch>
The revert command will create a new commit with the undo of the original commit.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With