149 | | Final note: conflicts can always happen, it's not your fault.[[BR]] |
| 149 | == 2A. Cherry-pick cleaning local master == |
| 150 | |
| 151 | Assuming (use export to set them in bash): |
| 152 | {{{ |
| 153 | rejcomm=sha-of-your-rejected-commit |
| 154 | lastgood=sha-before-your-rejected-commit |
| 155 | }}} |
| 156 | |
| 157 | {{{ |
| 158 | #branch from last good commit |
| 159 | git checkout -b re-patch $lastgood |
| 160 | |
| 161 | #cherry-pick rejected patch to be fixed, without committing it |
| 162 | git cherry-pick $rejcomm --no-commit |
| 163 | |
| 164 | #Amend the files, stage them with git add, then commit and create the new patch |
| 165 | geany fileToAmend |
| 166 | git add fileToAmend |
| 167 | git commit -m "old message /vN" #with N=2 to be incremented just in case |
| 168 | git format-patch HEAD^ # Works only with single last commit |
| 169 | |
| 170 | # Now you are left with the rejected patch still committed on the master |
| 171 | # and the "hopefully to be accepted" patch in your temporary branch |
| 172 | # A practical way to avoid merge conflicts and let you merge your branch |
| 173 | # and pull from master is to: |
| 174 | |
| 175 | # Revert the rejected patch on your master |
| 176 | git checkout master |
| 177 | git revert $rejcomm |
| 178 | |
| 179 | #merge your re-patch branch (should go without conflicts, if not see note) |
| 180 | git merge re-patch |
| 181 | }}} |
| 182 | |
| 183 | * NOTE: If you have more than one related commits (depending on) to the reverted patch (perhaps also to be amended), you can cherry pick also these to the branch and revert them in reverse order on the master. |
| 184 | * NOTE2: Still not know what to do if the dependent commits are from other authors (should not happen since the patch was not accepted) but I guess the method still applies as long as you add a patch taking care of such dependent commits. |
| 185 | |
| 186 | == Final note == |
| 187 | Conflicts can always happen, it's not your fault.[[BR]] |