LeesusFreak
LeesusFreak

Reputation: 133

Automatic stash/apply changes when changing feature branches

Essentially what I'm looking for is a way to treat each feature branch as a separate repository, as follows in this sample workflow:

1) If my active branch is Feature A, and I have "foo.cpp" modified and want to checkout Feature B, I want SmartGit to automatically stash my changes upon doing so.

2) Piddling around in feature B and then returning to feature A, I want it to stash my changes to feature A, then apply (and likely drop) the feature A stash created in at the tail of step 1.

Is there any way to do this automatically, or am I asking for something ridiculous?

Upvotes: 3

Views: 1120

Answers (1)

mstrap
mstrap

Reputation: 17443

SmartGit does not assign stashes to certain branches, but you can simply commit your modifications in A as a temporary WIP (work-in-progress) commit, then switch to B, continue working there, finally commit your changes again as WIP and switch back to A. Now you have several choices:

  • Local|Undo Last Commit to "unstash" your previous work;
  • just continue working and committing with Amend option to the existing WIP commit. Once your feature is ready use Edit Commit Message in the Outgoing view;
  • continue working and committing to a new WIP commit and once your feature is ready use Squash Commits in the Outgoing view to compact all your WIP commits into one tidy, final commit.

Personally, I prefer the last choice, because having several WIP commits lets me better review my progress (and see possible back-and-forth I did when switching between tasks).

Upvotes: 4

Related Questions