Jonathan E. Landrum
Jonathan E. Landrum

Reputation: 3172

IntelliJ IDEA doesn't recognize that my project is in git, has "N/A" for branch name

I am expanding on work done by another developer, and was given their existing code base over sneakernet. I started working on my local machine before the Git repository for the project was set up. Now, after getting access to the repository, I've cloned the repository to my local machine, set up my feature branch, added my changes to that directory, and have pushed my changes to the origin.

However, when I switched back to IntelliJ IDEA to continue working, it doesn't recognize that the project is now using Git. Where I would normally expect to see my branch name, it just says "N/A". How do I get IntelliJ to recognize that my project is a Git project now?

Upvotes: 1

Views: 3507

Answers (3)

whoami
whoami

Reputation: 11

If IntelliJ is in safe mode, version control is disabled.

Trust the project and version control will show up.

Upvotes: 1

ic3
ic3

Reputation: 7680

What worked for me is changing manually the vcs.xml file from the .idea folder.

Should be something like :

  <component name="VcsDirectoryMappings">
    <mapping directory="" vcs="Git" />
    <mapping directory="$PROJECT_DIR$" vcs="Git" />
  </component>

Upvotes: 3

Jonathan E. Landrum
Jonathan E. Landrum

Reputation: 3172

The problem

There are a few problems here that created the issue:

  • The previous developer wasn't using IntelliJ IDEA, so there was no existing settings directory telling the IDE about the VCS setup

  • The original project directory wasn't used, but was instead copied from, and the pulled directory became the new project root

  • The original project directory wasn't under VCS, so IntelliJ didn't know to even look for the branch name

The fix

In the toolbar menu, select VCS > Enable Version Control Integration, and in the popup window, select Git. Now all of the Git features you would expect to see are working.

Upvotes: 3

Related Questions