git checkout branch issues

Before filing a bug report on this I wanted to see if I'm doing something wrong. Whenever I attempt to check out a branch of a git repository I end up on (no branch) according to git bash's 'git branch' command, and PhpStorm itself gets messed up in Version Control -> Git -> Current Branch. It says:

<no active branch>
Repository: <none>
Branch: <none>

Has anyone else had this problem or am I doing something wrong?

Thanks and Best Regards

11 comments
Comment actions Permalink

Hi Howard,

So what do you actually do to checkout a branch?
You should use Version Control -> Git -> Checkout Branch for this.
The "Current Branch" action is for configuring the tracked branch for your current branch.

0
Comment actions Permalink

I am having the exact same problem, using PhpStorm 2.1 with msysgit.
I always use "Version Control --> Git --> Checkout Branch" to do the checkout of another branch, which always results in the problem described by the original poster.

0
Comment actions Permalink

Please tell what do you do to checkout a branch (an existing branch or a new one?) step by step. A screenshot would also help.

0
Comment actions Permalink

I do exactly that, the current branch example was just showing that PhpStorm is also unaware of where it is anymore.

0
Comment actions Permalink

Describe the operation step by step please. Preferably with a screenshot.

0
Comment actions Permalink

Here are the images, I just go to version control -> git -> checkout branch, select the branch and then click checkout and this is where it gets lost.

hope the images help.



Attachment(s):
phpstorm-gitbranchswitch3.PNG
phpstorm-gitbranchswitch2.PNG
phpstorm-gitbranchswitch1.PNG
0
Comment actions Permalink

I'm performing the exact same steps the original poster provided.
But I'll try again to describe everything in as much detail as possible.

No new branches are involved, all I'm trying to do is to switch between two existing branches.

Precondition: active branch of working directory is not "origin/master", but another existing branch. Let's call it branch "stable".

Step 1: open dialog "Version Control --> Git --> Checkout Branch"
Step 2: Choose branch "origin/master"

Result:

After background processing finished, current branch is "none". "Version Control --> Git --> Current Branch" says:


<no active branch>
Repository: <none>
Branch: <none>

The only thing which still works then is to switch back to original branch "stable". Switching to another existing branch besides the one already in use is not possible.

0
Comment actions Permalink

Andreas, Howard,

Both of you make the same mistake – you try to checkout a remote branch directly. In Git it is possible, but pointless because it leaves you in the state of "detached HEAD", i.e. on no branch.
You should checkout the remote branch as a new local branch that tracks this remote branch.
In command line you do:
  git checkout -b branchname origin/branchname
In IDEA you open the Checkout Branch dialog, select origin/branchname from the dropdown list and print "branchname" (or whatever name you choose for the local branch - usually the same as the remote branch has) in the "As new branch" text field.

You may read more about tracking remote branches by creating local ones, for example, here: http://progit.org/book/ch3-5.html
Hope this helps.

0
Comment actions Permalink

I see, thanks! Can the IDE perhaps throw a dialog up to prevent this from happening? also since local branches would be used more, can they perhaps be pushed toward the top of the list?

Thanks again and best regards, Howard

0
Comment actions Permalink

We don't want to prohibit checkouting a remote branch directly (there is a usage case actually - just watch around to see what's happening there, on the other branch, without committing anything).

But we can probably autofill the "As new branch" text field with a proposed name for new branch.

Sorting issue is fixed. You will get the change in one of the next updates or releases.

0
Comment actions Permalink

Thank you, I appreciate the awesome support!

0

Please sign in to leave a comment.