Cmag
Cmag

Reputation: 15770

Git and Github pull request stash commit messages

Folks, I have a branch testFeature which i branched off master. In this branch I've made hundreds of commits and modifications, which I now would like to send out for a pull request. Trouble is, most commit messages in there are irrelevant for code review.

How can I create a new branch from testFeature with only one commit message and use that branch for the pull request to be merged into master?

Thanks!

Upvotes: 2

Views: 1115

Answers (1)

gravetii
gravetii

Reputation: 9634

Ideally you'd want to squash all the commits into just one.

For doing that you would need to identify the first commit you have made in your testFeature branch and then get the SHA of that commit's parent commit.

Once you have that you can squash your commits using git rebase.

git rebase -i <SHA of parent commit>

There you will be presented with an interactive view to squash and pick commits. This view contains commits such that the top most commit is the parent of the second commit, the second commit is the parent of the third commit and so on. Here, note what git tells you about squash: s, squash = use commit, but meld into previous commit. So ideally you will mark all the old commits as s and pick the most recent commit (if you want just one commit).

You can of course also change the final message of the squashed commit right after you move out of the interactive view for squashing and picking the commits you want.

Here's a good tutorial that might help you get started.

Hope this was what you were looking for.

Upvotes: 2

Related Questions