Git Pull Request

Asked

Viewed 71 times

0

I have a branch where I had to do several commits to test CI/CD, and this branch has an open PR. However these commits were test commits and I don’t need their history. In most cases I commented something like: "testing CI/CD".

How do I reset the commits on this branch by showing only the last commit in the history? This is possible?

What happens for example if I delete this branch associated with this PR both at origin, recreate local and resubmit with pull?

Detail there have been comments in this PR.

Thank you so much for your help.

  • I don’t see much point to keep doing something and erasing, the history is to know even what you did and even to return to such a point if necessary.

  • @Felipe if I get it, you want to use the Squash and Merge option of a Github PR. Read it and see if it meets your need

1 answer

0

You can use iterative rebase to edit the git commit history. Let’s assume the commits you’re referring to are the last five, so you could do git rebase -i HEAD~5, where 5 are the 5 commits you want to change. After that, git will open the default editor with the list of commits and a comment just below with the available options. By default all commits are marked with pick (or p), which means using the commits and so does not change anything, but you can put s of squash, for example, that will merge that commit with the previous one and allow you to edit the message in sequence. Or, use f of fixup, that will join the wrong commit to the previous one, such as squash, but will discard the message. The other options will be in the cited comment.

  • Solved with your suggestion. Thank you very much for the support. Sensational!!!!

  • Supplementing the answer: https://answall.com/q/81221/99718

Browser other questions tagged

You are not signed in. Login or sign up in order to post.