Niklas Schandry
01/27/2026, 3:35 PMdev ) for a long time, and by now this branch contains a bunch of commits that largely replace what previous commits (in the same branch) did, etc. dev has also been updated with template updates meanwhile.
In this case, what can I do to make this the less of a mess? I am aware that the number of commits do not matter so much for reviews, but a bunch of them are simply obsolete by now. Is it considered a major git-crime if I simply create a new branch from current dev and copy all of my changes that are not part of the template into that clean branch and create reasonable commits? There is no one else working on this branch.Evangelos Karatzas
01/27/2026, 3:38 PMNiklas Schandry
01/27/2026, 3:38 PMEvangelos Karatzas
01/27/2026, 3:39 PMEvangelos Karatzas
01/27/2026, 3:40 PMNiklas Schandry
01/27/2026, 3:40 PMJames Fellows Yates
01/27/2026, 4:07 PMNiklas Schandry
01/27/2026, 4:47 PMpontus
01/27/2026, 5:22 PMdev, copying in your changes and working with git diff to check that you don't undo any changes from the source branch tends to be the least bad experience.mashehu
01/27/2026, 5:53 PMNiklas Schandry
01/27/2026, 6:05 PMmashehu
01/27/2026, 6:18 PMpontus
01/27/2026, 7:09 PMgit squash comnand, right? You can either do a squash with git rebase (which allows for reordering) or git merge (which will squash everything that applies)?mashehu
01/27/2026, 7:12 PMNiklas Schandry
01/28/2026, 7:58 AMMatthias Zepper
01/28/2026, 1:02 PMdev. Then you can use git cherry-pick SHA to selectively apply commits from your long-term working branch to the clean new branch. If you do it approximately chronologically and performed relatively atomic commits, you should not get terribly many merge conflicts.
⢠The actually not too scary alternative is exactly what @mashehu suggested: An interactive rebase on the branch itself. After creating a backup of your branch (!), you can run git rebase --interactive HEAD~10 . In this case, the last 10 commits on that branch are being included into your operation. You will see a text file that represents the working plan for the rebase. In this text file, you see the SHAs and commit messages of all relevant commits:
pick 110c33e Something
pick 01c131a Something else
pick 39fba8c Another thing
The word pick indicates that these commits should be kept as they are. But you can (it is described in the text) also choose other actions such as
drop 110c33e Something
squash 01c131a Something else
reword 39fba8c Another thing
In this case, the commit Something would be skipped and ignored, Something else would be combined with the changes in Another thing and you could edit the commit message to e.g. say Something and another thing added.
If you hit a merge conflict, you can manually resolve that, run git add file
to indicate that everything has been resolved in that file and then git rebase --interactive --continue to proceed.mashehu
01/28/2026, 1:08 PMNiklas Schandry
01/28/2026, 1:11 PMIf you do it approximately chronologically and performed relatively atomic commits, you should not get terribly many merge conflicts.Around half of my commits are "here is what I managed to do today" the other half is "fixing yesterdays mistake", so they are not atomic... A GUI for rebase would be really nice, but anyways, since I will squash-merge this, I realize there is not much of point in cleaning up the commit history of the branch
Niklas Schandry
01/28/2026, 1:13 PMmashehu
01/28/2026, 1:14 PM