Question

I've tried looking around but can't seem to find an answer for my specific question.

I'm using GitHub for Mac (because I'm a sissy and can't deal with the terminal, so please keep your answers conceptual and syntax-free) and this happens to me often:

I'm making some changes, and as I save my files GitHub for Mac automatically stages them. Before I'm done, however I notice I need to make one or a few small unrelated changes. Since these are unrelated to the feature I'm working on, it wouldn't be right to make the these changes in the same commit. Lately I've just been writing it down on a To Do list for later, and once I'm done with what I'm working on, I'd go back and do a new commit of the things I wrote down on my To Do list.

This workflow is really stressful. I'd like to be able to just create a new branch, quickly make the small changes and commit them (and possibly, but not necessarily, merge the new branch into the old one), then switch back to the old branch and continue working.

One time I staged some changes, but created a new branch from where I was without committing the changes. Then when I switched to the new branch, all of my staged, uncommitted changes transferred to the new branch! When I switched back to the old branch, the staged changes were gone. This defeated the purpose of creating the new branch; I wanted to do so in order to keep the features separate. Now the best thing I can do is to commit all the staged changes to the new branch and then merge it back into the old one.

Expected Result:

I'd like to be able to stage some changes without committing, then create a new branch off of the last commit to the current branch. The new branch wouldn't have any of the staged changes; it would just be a copy of the old branch up to the most recent commit. The staged changes would still be on the old branch. On the new branch, I could quickly work on the small feature and commit it, then switch back to the old branch with all of my uncommitted changes still there.

Then I could either continue working on the changes, commit them to the old branch, then merge the new branch in, or I could merge the new branch into the old one immediately and continue working after the merge. Either would be acceptable.

References:

No correct solution

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top