How to exclude specific commit from series of commits. I mean if I have 5 commits, and I only want to push 4 commits. How to do this. Please help to resolve this.
You will need to have a new branch with the desired commits.
You can do it in several ways
git cherry-pick
Checkout a new branch to the specific sha-1 you want to start from:
git checkout <origin branch>
git checkout -b <new branch>
# now cherry-pick the desired commits onto the new branch
git cherry-pick commit1 commit2 ... commitN
# now push to remote
git push origin remote <branch name>
git revert
git revert SHA-1
Use git revert to undo the changes you have made in the unwanted commit, the result will be branch with the old code and the new code but the current state will be the original code
git rebase -i
Interactive rebase. choose the commit you don't want and remove it.
# X is the number of commits you wish to squash
git rebase -i HEAD~X
Once you squash your commits - choose the e
for edit and place the code you want it to be, add and commit
git filter-branch
Filter branch can be used to filter any content you want.
git filter-branch --env-filter '<do what ever you want on this commit range' SHA1..SHA1
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