On my personal projects, I often have to switch the machine I am working on and therefore I use git to synchronize my progress. A side effect of this workflow is that I sometimes have to push unfinished states to my remote so that I can continue to work on the problem at my other machine.
When I have finished working on such a commit, how can I rebase my changed onto the remote commit, so that this unfinished commit doesn't exist anymore?
For example this is what my history would look like after I commited an unfinished to the remote and pulled this commit to the machine I am now working at.
* commit b995e2580c76badd9487f9d192acf4aae631a4f9 (HEAD -> main, origin/main)
| Author: John Doe <johndoe@mail.com>
| Date: Mon May 22 16:27:50 2023 +0200
|
| Unfinished, broken state while solving problem A
|
| The only reason this commit exists is to
| synchronize progress between different
| machines.
|
* commit 8604e39ac0fed96e805f67bd63216f4aab492323
| Author: John Doe <johndoe@mail.com>
| Date: Mon May 22 09:05:58 2023 +0200
|
| Previous commit
|
Then I would solve the given problem and create a new commit so that my history looks like this.
* commit 0527d493ab8a959bcb8a672f0710cb685ffc87a9 (HEAD -> main)
| Author: John Doe <johndoe@mail.com>
| Date: Mon May 22 16:48:53 2023 +0200
|
| Solve problem A, reach a finished state
|
* commit b995e2580c76badd9487f9d192acf4aae631a4f9 (origin/main)
| Author: John Doe <johndoe@mail.com>
| Date: Mon May 22 16:27:50 2023 +0200
|
| Unfinished, broken state
|
| The only reason this commit exists is to
| synchronize progress between different
| machines.
|
* commit 8604e39ac0fed96e805f67bd63216f4aab492323
| Author: John Doe <johndoe@mail.com>
| Date: Mon May 22 09:05:58 2023 +0200
|
| Previous commit
|
However, I would like to do a rebase or similar so that my history looks like this in the end.
* commit b995e2580c76badd9487f9d192acf4aae631a4f9 (HEAD -> main, origin/main)
| Author: John Doe <johndoe@mail.com>
| Date: Mon May 22 16:27:50 2023 +0200
|
| Solve problem A
|
* commit 8604e39ac0fed96e805f67bd63216f4aab492323
| Author: John Doe <johndoe@mail.com>
| Date: Mon May 22 09:05:58 2023 +0200
|
| Previous commit
|
Thus far I have not been able to achieve this so that I always ended up with the unfinished commit left behind. Is there a way to get from the second history snapshot to the third? Otherwise, do I maybe need to use a different workflow?