Skip to content

Instantly share code, notes, and snippets.

@miloskroulik
Created March 23, 2015 15:35
Show Gist options
  • Save miloskroulik/59493277fa0f71c5566b to your computer and use it in GitHub Desktop.
Save miloskroulik/59493277fa0f71c5566b to your computer and use it in GitHub Desktop.
How to update stale patch with GIT (also known as rerolling) #git #patch
  1. Update to the latest version of the project you're working with.
  2. Use git log to find the hash of a commit near or just before the time the patch was posted.
  3. Create a branch from that commit: git checkout -b <date_based_branch_name> <commit_hash>. (I often use the date for the branch name: git checkout -b aug10 <hash>
  4. Apply the patch. It should apply cleanly unless there was already something wrong with it when it was created.
  5. Use git add and git statusto make sure that all your changes are staged, then commit the results.
  6. Create a new branch for the updated patch. I'll use git checkout -b bundles_removed_1245332_04 origin/8.x, which branches off of 8.x just for this feature branch.
  7. Merge the date-based branch: git merge <date_branch>
  8. If all goes well, you have a clean merge, and you can create a patch. In this case, git diff origin/8.x >drupal.bundle_warning_1245332_04.patch
  9. If you still have a merge conflict, you probably only have the really relevant part of the conflict (changes actually made in your patch which conflict with changes which have been committed since the issue was last active.) In that case, you can use git mergetool to reconcile the differences, but that's for another session.

Source: http://www.randyfay.com/content/refreshing-stale-patch-git

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment