Git - local workflow when working with codebases and branches

My local workflow when working with branches

  1. Local branch
  2. Keep committing changes to it consistently
    1. Another approach is to move changes to the staging area
  3. Before switching to other branches, or pulling or merging or pushing to remote, squash.
    1. This will keep the history a little cleaner.
  4. Use stash sparingly.
    1. When we create branches from stashes, it includes everything from the stash into that branch.
    2. If there are changes that I want to keep in local only (not push it to remote ever), it gets tricky.

Complex codebase. Working with two workspaces.

  1. Keep making all changes on workspace1.
  2. Keep committing minor changes on workspace1. These are changes that will need to go to main eventually. These commites can be as small as you want - because these commits will never leave your machine.
  3. When the work is in a reasonable shape, stash all changes that shouldn’t leave your computer.
  4. Now compare workspace1 with workspace2. Pull all the necessary changes into workspace2.
  5. Create new commits and PRs from workspace2 (preferable, after rebasing from main).
  6. Hard reset workspace1 and pull down from main.

Links to this note