1

I have found that the best way to deal with pull requests that have failed validation due to coding standard error is to close the PR, delete the remote branch in Git and create a new one with the corrected code pushed to it. This is, of course, a bit fiddly and one would rather get the standards right first time. Is this the correct approach? Simply pushing a new commit causes grief in that the local and remote branches are out of sync.

1
  • I don't understand what you mean by "causes grief", can you be more specific? Oct 10 '16 at 21:49
2

You can add a second commit and push to the same branch, which is what I'd generally do. The PR will be updated with additional commits to the PR's branch.

git add --patch
git commit
git push REMOTENAME BRANCHNAME

If your branch hasn't been merged (and you're not concerned about others having worked on the same branch), you can also amend your commit and then force-push. But this is more likely to cause grief IMO.

git add --patch
git commit --amend
git push -f REMOTENAME BRANCHNAME

If you really regret a PR, you can delete the remote branch and start over. This will probably destroy the PR, but you can make as many branches and pull requests as you like.

A colon before the branch name will push "nothing" to that branch, deleting it.

git push REMOTENAME :BRANCHNAME
2
  • I have had problems pushing the second commit to the remote branch. I forget the exact error message. So, it seems easier to close the PR, delete the remote branch and start again. Next time I have to do a PR, I'll have another look. Oct 12 '16 at 9:25
  • I have found that once your forked master gets behind Civicrm/civicrm-core master the only way round is to delete your fork and clone from the CiviCRM repository, re-apply the changes and hope the master isn't out of date before submitting the PR. I have tried various forms of rebasing, but none seem to work. Any suggestions? Submitting PRs takes much longer that fixing the code, and the risk is that you get the changes wrong after so much fiddling around. Jan 4 '17 at 18:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.