Many times, as an open source project maintainer, I’m tasked with reviewing pull requests that community members have contributed to our project. It’s honestly one of my favorite things to do. Seeing community collaboration on projects is awesome, and really helps me feel a purpose to what I do on a day to day basis. While any pull request is typically welcome, there are times when slight edits are needed to meet project guidelines or coding standards.

Edit a pull request and maintain commit history

The worst thing I could do as a maintainer is reject someone’s code on they whitespace issues alone. I’d love to have the whitespace perfect, but as long as the code works and achieves the task in a manor I feel adequate, whitespace changes or docblocs should not matter.

The key here though, is I shouldn’t lose someone’s commit history, since they deserve credit for the initial work they’ve done. So here’s how I handle this.

First, if an issue doesn’t exist for the pull request I create one. That’s important later.

We’ll assume 2 things here in my code:
1) The Pull Request number is 123
2) The Issue number is 567

git fetch origin pull/123/head:pull/123
git checkout pull/123
git checkout -b issue/567 pull/123
// Make changes
git push origin issue/567

From that point you can close the original Pull Request in 123 without merging, and after making your edits and pushing to the issue/567 branch, create a new pull request. This new pull request, will have all the necessary commit history to retain credit for the original Pull Request author.

Posted by Chris Klosowski

Chris Klosowski is the Director of Technology at Sandhills Development, LLC, creators of fine WordPress plugins, and ecommerce solutions.

16 Comments

  1. Hello,

    It is with sad regret to inform you that BestLocalData.com is shutting down.

    We have made all our databases for sale for a once-off price.

    Visit our website to get the best bargain of your life. BestLocalData.com

    Regards,
    Isidra

    Reply

  2. This paragraph is genuinely a nice one it helps
    new internet people, who are wishing in favor of blogging.

    Reply

  3. It is with sad regret to inform you that because of the Covid pandemic BestLocalData.com is shutting down at the end of the month.

    We have lost family members and colleagues and have decided to shut down BestLocalData.com

    It was a pleasure serving you all these years. We have made all our databases available for $99 (All of it for $99) for those interested.

    Kind Regards,
    BestLocalData.com
    Mable

    Reply

  4. Hi ,

    I am following up on my message below.

    Who would I speak with about handling your US order fulfillment and shipping?

    Regards,
    Rene
    order-fulfillment.net

    ————————————————————————

    Hi,

    Who would I speak with at your company that manages your product shipping and order fulfillment?

    We are US company, offering warehousing, order fulfillment and drop shipping to our customers since 2005.

    Here are some of the items we ship for clients:

    -Books, training manuals, guides
    -E-com product drop shipping
    -New member welcomes boxes and gifts
    -Product samples
    -Health and Medical supplements
    -Marketing materials
    -Medical program test kits
    -Follow up gifts to clients, leads, and prospects

    Do you have some time to discuss – phone / email ?

    Thanks,

    Fulfillment Specialist
    http://www.Order-Fulfillment.net

    Reply

  5. When someone writes an paragraph he/she keeps the image of a user
    in his/her brain that how a user can be aware of it.
    Therefore that’s why this article is perfect.
    Thanks!

    Reply

Leave a reply

Your email address will not be published. Required fields are marked *