Git Course 0%

Install, Git executable, enable VCS

Beginner IntelliJ UI ≈ 8 min

What you will learn

  • How IntelliJ finds Git and what to do when it cannot
  • How to put an existing project under version control
  • The settings that decide how the commit workflow behaves

After this lesson you can

  • My IDE and my Git agree, and the project is under version control

Why this matters

Two settings decide how the rest of this section feels: where Git is, and whether the staging area is switched on. The second is the bigger decision, because it chooses between IntelliJ's own way of organising work and Git's.

Finding Git

IntelliJ runs the git binary; it does not include one. Settings (⌘, on macOS, Ctrl+Alt+S elsewhere) → Version Control → Git has a Path to Git executable field with a Test button that reports the version.

If Test fails:

  1. Confirm Git is installed: git --version in a terminal.
  2. Find its path: which git, or where git on Windows.
  3. Paste that path into the field and click Test again.
  4. On Windows, the usual path is C:\Program Files\Git\bin\git.exe.

Putting a project under version control

If you opened a folder that is not a repository:

Route Result
VCS Operations Popup (⌥) → **Enable Version Control Integration** → Git |git init` at the project root
VCS → Create Git Repository… git init in a directory you choose, for a project with several repositories

Afterwards, the Commit tool window shows every file under Unversioned Files, which is IntelliJ's name for untracked. Nothing is in Git until you add and commit them.

If the project is already a clone, IntelliJ detects the repository when you open the folder and the Git menu appears by itself.

The settings that matter

Settings → Version Control → Git:

Setting Suggested Why
Enable staging area On, if you know Git Uses Git's real staging area instead of changelists (lesson 16.5)
Update method Merge or Rebase, matching your team Decides what Update Project does (lesson 7.5)
Auto-update if push was rejected Off while learning So a rejected push is something you see and understand
Warn if CRLF line separators are about to be committed On Catches the Windows line-ending problem early (lesson 4.5)

Settings → Version Control → Commit holds the workflow options: whether the commit window is a tool window or a dialog, and the Before Commit checks such as reformatting and optimizing imports.

Identity

IntelliJ uses your Git configuration for the commit author, so git config --global user.name and user.email still apply (lesson 3.3). If a commit ever shows the wrong author, that is where to look, not in the IDE's settings.

How to do it

Terminal
$ git --version
$ which git
$ git config --global user.email

Those three answer everything in this lesson except which options IntelliJ has switched on.

Common mistakes

  • Expecting IntelliJ to include Git. It runs the one you installed.
  • Leaving Before Commit reformatting on, which adds unrelated changes to every commit.
  • Turning the staging area on without knowing what it is, then finding the commit window unfamiliar.
  • Adding everything at the first commit, including secrets and build output.
  • Looking for the commit author in IDE settings. It comes from git config.

Try it yourself

Goal: connect the IDE to Git and make one deliberate commit.

  1. Open Settings → Version Control → Git and click Test beside the Git path.
  2. Decide on the staging area: on if you have used git add, off if you have not, and note which you chose.
  3. Open Settings → Version Control → Commit and confirm no Before Commit reformatting is enabled.
  4. On a folder that is not yet a repository, use Enable Version Control Integration, write a .gitignore, then add and commit the files you actually want.
  5. Run git log --oneline -1 in the IDE's terminal to confirm the commit and its author.

Expected result: a working Git integration, a repository created from the IDE, and a first commit whose contents you chose.

Show solution

Step 2 is the decision that shapes the rest of the section. With the staging area on, the commit window behaves like git add; with it off, you get changelists, which are IntelliJ's own idea and explained in lesson 16.5. Neither is wrong; knowing which you have prevents a lot of confusion.

Check yourself

1. Where does IntelliJ get the author name on your commits?
2. What does Enable Version Control Integration do?
3. Why leave Reformat code off in Before Commit?

Key terms

IDE Configuration Repository (repo)