[Solved] What is a good git practice for working on multiple files over multiple days before pushing


You should be squashing commits, rather than amending the same commit over and over. Even if you commit sloppily at first, if you’re a perfectionist, you can go back and edit your history with git rebase -i.

This is what it would look like with 3 commits where you want the 3rd squashed into the first. When you first run git rebase -i it will show you something like this:

pick some_hash1 1st change
pick some_hash2 2nd change
pick some_hash3 3rd change

Edit that file so that it shows this:

pick some_hash1 1st change
squash some_hash3 3rd change
pick some_hash2 2nd change

Then close it. You may have to do some fixup and run git add -A && git rebase --continue but it’s pretty intuitive.

2

solved What is a good git practice for working on multiple files over multiple days before pushing