• nous
    link
    fedilink
    English
    arrow-up
    2
    ·
    2 months ago

    I no longer use git stash. I found far too many issues with it. Merge conflicts and old no longer useful stashing building up, forgetting what was on it and which branch it came from and other things. These days the only time I stash is with --autostash on a git rebase as that is very temporary.

    Instead I have moved to a worktree where I just commit everything on the main branch. Then use a different worktree to create a branch and cherry pick from main and create prs from that branch.

    No need to stash as my main worktree never changes off the main branch and my second worktree never has local changes that are not committed.

    If I need to change focus or fix a bug I can just do that, commit those changes only and cherry pick to a new branch all without affecting my current work (assuming I have not changed the area the bug is in too much but that is not a big issue if you keep commits small and create PRs often so you don’t drift too far from master).

    If I have drifted too far I can always create a new worktree from origin and not touch my local main.