Folding git commits
I think that there must be a commit per feature. However, one big feature consists of series of useful pieces. Consider refactoring. Though, others say that refactorins are side effects of adding/modifying functionality and do not deserve a separate commit, consider I do a couple of fixes in the code. They all refactor different areas of the codebase. I do not want to commit a big mess so that it is difficult untangle, which changes are related. I therefore spawn more than one refactoring commit. However, most likely, people do not want to see all those tiny details. I therefore want to hide all refactoring commits under one folder of commits. In the history viewer, like gitk, I then should be able to expand/collapse the folder when desired. Is there a solution to this issue, might be solved in some other versioning control?
2 Solutions collect form web for “Folding git commits”
Use feature branches. Merge them into the mainline with
git merge --no-ff. The mainline is then just a series of merge commits that show one feature added another, but if you want to see the individual commits that went into a feature, they’re right there on the branch.
I do not think it is possible to fold commits in gitk, maybe another viewer can do this. However, you can:
- Use interactive rebase to squash or fixup commits in one (History will be lost)
- View a diff for a range of commits:
sha1..sha2. All changes from
sha2will be viewed as one change.