gitgit-rebasegit-merge-conflictgit-squash

Git squash old commits


I have a git log like this

* cb0bfd5 (HEAD -> feat/nuxt, fork/feat/nuxt) Split into icons
* f2d2410 fix: buttons spaces & move layouts to components (#3)
* 881d4ab Split into Components, migrate to nuxt
* c0ff57b Split components (#2)
* dbfa29b Improve workflows and docker
*   92d449d apply updates from master (#1270)
|\  
| * 0bf266d npm: package updates
| *   0ca39b4 fix(Doc): fix escaping issue for PASSWORD_HASH in docker-compose.yml (#1270)
| |\  
| | * a268422 fix(Doc): fix escaping issue for PASSWORD_HASH in docker-compose.yml
| |/  
* | 3cba455 Merge remote-tracking branch 'origin/master' into feat/nuxt
|\| 
| * 8921d6c docker-compose.yml: reflect How_to_generate_an_bcrypt_hash.md
| * b18f919 fixup How_to_generate_an_bcrypt_hash.md
| *   ea99f56 Update How_to_generate_an_bcrypt_hash.md (#1262)
| |\  
| | * aea653a Update How_to_generate_an_bcrypt_hash.md
| |/  
* | 053f1df use auto imports
* | 9c883cb Split components (#1)
* | cb8428e Merge remote-tracking branch 'origin/master' into feat/nuxt
|\| 
| * a18a715 npm: package updates
| *   ec202d8 fix: Status Bar Color Issue in PWA on iOS 18 (#1257)
| |\  
| | * 9dd7f25 fix: Status Bar Color Issue in PWA on iOS 18
| |/  
* | e2facd4 reduce errors, improve typing
* | 6d0a45b improve dx
* | 7f3a8d7 update translation to match new theme mode
* | a847956 Merge remote-tracking branch 'origin/master' into feat/nuxt
|\| 
| *   33e95ba Update Ukraine translation (#1251)
| |\  
| | * 72fe643 Update i18n.js
| |/  
| * 2b7c846 npm: package updates
| *   9275cf6 Add autocomplete attribute to password input (#1249)
| |\  
| | * 95934c6 Add autocomplete attribute to password input
| |/  
* | 75c64ab better local dev while dev container is running
* | ea9f134 !! use better storage key name
* | 0ee7baa use color mode plugin
* | 754aa82 add pinia
* | 693daa5 add more jobs to check for good code
* | 8850b3c use zod to validate input
* | fcf8adb correct key for api errors
* | 2133178 convert undefined to boolean
* | c962f67 correct session middleware, type safe session
* | 3040bd4 fix error
* | 51c9907 update workflows
* | dbc1b85 change default working directory
* | 4754f67 better return types
* | 93e527a use type safe api, fix typescript errors
* | 6ca6b18 split files into correct methods
* | 1384d68 Fix session middleware
* | 2a41ee3 fix lint action
* | dd83e59 fix logout not showing
* | a419a30 fix tailwind problems
* | 1e7ae10 fix styling issue, fix formatting
* | 73a2e1c cache config
* | bc73d54 add prettier eslint config
* | c616bd8 use auto imports
* | f96cc76 better typescript
* | e31c210 fix lint, add vscode settings
* | de2ee3d add prettier, format
* | bfaaceb lint fixes
* | a1f5313 fix lint workflow
* | 619d532 typescript, vendors
* | 48bba9e add wireguard routes
* | 78f295b fix styling
* | 4c0bc9d add docker dev script
* | 74f327f install correct bcrypt, move eslint to dev modules
* | 2d9717a add types, fix wrong error message
* | fd9fa66 update workflow, add eslint
* | 6c09155 add changes from c9ff248
* | 3fa4f47 basic implementation
* | cc69073 wip: add nuxt

I want to squash commit cc69073 upto including 693daa5. (there are more commits before this)

But even if rebase and do nothing I have way to many merge conflicts

Run git rebase -i HEAD~52 and squash the commits but I get many conflicts.

Try git Rerere but it did nothing.

Is there any way to auto resolve the merge conflicts? As I don't really see the reason for these conflicts. As I already merged them (where I had conflicts and resolved them)


Solution

  • Sounds like you should take a look at https://github.com/eantoranz/git-duplicate

    git checkout -b temp 693daa5
    git reset --soft cc69073
    git commit -m "Squashing cc69073..693daa5"
    ./git-duplicate.sh 693daa5 feat/nuxt
    

    I think that will pull it off. After running, it will print a commit id that has a history like what you are after (do not trust me, double check that is the case by checking it out and checking its history). If that is the case, then force the branch to be on top of that commit (and force-push where needed)..... You are rewriting history so I guess you already know all the consequences and how to deal with them.