Using Lazygit makes this workflow much easier.
How to implement the workflow:
-
Set
git config pull.rebase trueandgit config merge.ff onlyin your local project. -
Avoid
git add ., and instead prefer adding and creating commits for files, that contribute to a specific change. For example one for documentation changes and another for the actual feature changes. -
Use
git rewordto change commit messages, that don't conform to conventional commits. -
Use
git fixupto fix broken commits. Each commit should represent a new working version of the application. You can create temporary commits to save your work, but try to merge all related commits to its own separate feature commit before merging.- Follow this for merging unstaged changes. In short, stage all files, navigate to your desired commit and press
Ato amend. - If you want to merge two older commits, use Lazygit. Use
ctrl + j(one down) andctrl + k(one up), to move commits around. Move the desired commit on top of the other commit and then fixup them together.
- Follow this for merging unstaged changes. In short, stage all files, navigate to your desired commit and press
-
Don't be afraid to use
git push --forcein your personal branch, if you rewrite history with any of the previous actions. -
Use the Git CLI locally to merge your (or your friends) branch to master and then push it to remote. Github does not support fast-forward merges in the web UI.