11 ms·
Honestly I stash only cause I don't fully understand how to branch and bring my changes with me when I realize I should have branched earlier
by kkirsche 10y ago
Honestly I stash only cause I don't fully understand how to branch and bring my changes with me when I realize I should have branched earlier
- dahart 10y agoThis is a great answer, honestly, and you're not alone. FWIW, here's how. Since stash only captures uncommitted changes, I assume you're working on master and want to create a feature branch, and you've already made some changes for the branch. git checkout -b myFeature That's it. Uncommitted changes aren't in a branch yet, so they don't have to be stashed before you make a new one. You can always start a branch from wherever you are, and switch to it, and your changes will be right there. Now you can commit, and your commit will be on the branch myFeature. BTW, you can switch branches without stashing too. Git will prevent you from messing up your uncommitted changes. If that happens, then you can commit or stash first. The safest course of action is always to commit any changes first before you do anything. It's also easy to build your feature branch if you have both committed and uncommitted changes already, or if you want to base your feature branch off a different branch than the one you're working in. I'm already spamming you, so just say so if you'd like me to outline those.
- kkirsche 10y agoThank you for explaining this! I didn't know that and will start incorporating that into my workflow :) thanks for teaching me something new!