| 1 | = Cleaning your local history = |
| 2 | |
| 3 | Assuming the case you push end-of-day dummy-message commits to a backup bare remote for your development, so that you have a ''long'' history. |
| 4 | (And that public tracked branches are left clean for git-pulls and local comparisons). |
| 5 | |
| 6 | When applying patches out of your local commits, it seems it can happen that the checksums on the (public) feature branch could get different (maybe due to whitespace problems, or so). |
| 7 | |
| 8 | In order to have a ''clean'' history, with identical SHA-1 hashes and hence common ancestors actually recognized, you could clean it up by moving the ''unpatched'' commits on top of the feature branch. |
| 9 | |
| 10 | This means for instance, if you are working on a '''''feature_X_local''''' branch for development work on the public '''''feature_X''''' feature branch: |
| 11 | |
| 12 | {{{ |
| 13 | o-------o-------o-------o-------o-------o master [public] |
| 14 | \ |
| 15 | o------o----A'-----B'-----C' feature_X [public] |
| 16 | \ | | | |
| 17 | \ /-pA /-pB /-pC |
| 18 | A------B------C-----D----E feature_X_local [local] |
| 19 | }}} |
| 20 | |
| 21 | `pA`, `pB` and `pC` are _patches_ you sent through the [http://rasdaman.org/patchmanager Patch Manager], and it happened you had different checksums between your local and public commits (`A!=A'`, `B!=B'`, `C!=C'`). |
| 22 | NOTE: Despite of this, always check that a patch can apply (`git apply --check`) before submitting them. |
| 23 | |
| 24 | If you want to clean your local history at some point, you need to bring `D` (and `E`) on top of `C'`, the `HEAD` of '''''feature_X''''': |
| 25 | |
| 26 | {{{ |
| 27 | #!sh |
| 28 | $ git stash |
| 29 | $ # branch situation |
| 30 | $ git branch |
| 31 | feature_X |
| 32 | master |
| 33 | * feature_X_local |
| 34 | $ # create a temporary branch which HEADs to the last /patched/ commit (`C`) |
| 35 | $ git checkout -b _tmp PetascopeSecore |
| 36 | $ git reset --hard C # see "C" node in the graph above |
| 37 | $ # move commits /from/ the common ancestor (ie C) between tmp_branch and feature_X_local (ie {D,E}) on top of feature_X |
| 38 | $ git rebase --onto feature_X _tmp feature_X_local |
| 39 | }}} |
| 40 | |
| 41 | Done: |
| 42 | |
| 43 | {{{ |
| 44 | o-------o-------o-------o-------o-------o master |
| 45 | \ |
| 46 | o------o----A'-----B'-----C' feature_X |
| 47 | \ |
| 48 | D----E feature_X_local |
| 49 | }}} |
| 50 | |
| 51 | It can also happen that some unpatched commits are ''in between'' other patched commits (some hotfix?): in this case you can just rewrite your local history by moving all ''patched'' commits before the unpatched ones beforehand (`git rebase -i HEAD~N ...`, see [attachment:Git4rasdaman.pdf:wiki:ProvideFix Git4rasdaman]). |