Best way to switch from branch with local changes and then back

已回答

I have local changes (not committed) on my branch, and I want to quickly switch to a different branch, and then back to my original one with my local changes.

The usual way to do this is by stashing the local commits; but this requires several extra commands to stash, unstash, and then delete the stash. I do NOT want to commit my changes; sometimes I do, but in this scenario I'm experimenting and I really don't want commits.

Is there a faster way IntelliJ way that does this all for me? I need to do this quite often to review pull requests or other changes from my team.

Thank you!

0

> I have local commits on my branch, and I want to quickly switch to a different branch

If changes are already committed, a simple checkout would do. That's the purpose of git branches.

> The usual way to do this is by stashing the local commits

You probably mean uncommitted changes, not commits. It is not possible to stash a commit, only uncommitted changes can be stashed.

> Is there a faster way IntelliJ way that does this all for me? 

It seems what you are looking for is a feature that will associate uncommitted changes with some branch. There is no such a feature in the IDE, and similar requests are tracked as https://youtrack.jetbrains.com/issue/IDEA-90151

> but in this scenario I'm experimenting and I really don't want commits.

As a side note, commits in git can be easily undone, so committing some WIP to switch to another task is rather common workflow

2

Yep, I meant uncommitted changes and ideally associate uncommitted changes to a branch. I will probably submit a feature request, thanks!

0

请先登录再写评论。