Git - local workflow when working with codebases and branches
Table of Contents
My local workflow when working with branches
- Local branch
- Keep committing changes to it consistently
- Another approach is to move changes to the
stagingarea
- Another approach is to move changes to the
- Before switching to other branches, or pulling or merging or pushing to remote,
squash.- This will keep the history a little cleaner.
- Use stash sparingly.
- When we create branches from stashes, it includes everything from the stash into that branch.
- 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.
- Keep making all changes on workspace1.
- Keep committing minor changes on workspace1. These are changes that will need to go to
maineventually. These commites can be as small as you want - because these commits will never leave your machine. - When the work is in a reasonable shape, stash all changes that shouldn’t leave your computer.
- Now compare workspace1 with workspace2. Pull all the necessary changes into workspace2.
- Create new commits and PRs from workspace2 (preferable, after rebasing from main).
- Hard reset workspace1 and pull down from main.