Forget the CLI — how to master Git in the IDE

Typing hard-to-memorize commands might make you feel like a movie hacker, but there’s a better way: Learn how to use Git in the IDE

By Ronny Shani

Working with Git in the command line might make you feel like the quintessential movie hacker, but in reality, typing hard-to-memorize Git commands in the terminal just isn’t worth the effort.

Marco Gregorini, a Senior Software Engineer @Project A’s Tech team, suggests using the IDE for Git operations.

Marco works on Linux (Ubuntu) and uses JetBrains IntelliJ IDEA, leveraging its native support for version control. Most of his day-to-day work involves quickly jumping into new projects and getting comfortable with unfamiliar codebases, so he counts on features like autocomplete and keyboard shortcuts to be faster, more efficient, and achieve more with less.

It’s not an ideological choice; it’s about finding a better, easier way of doing things

Checkout the workflow

Here are typical Git commands he runs in the IDE rather than the Command line interface (CLI):

  • rebase — using the IDE is much more intuitive than the CLI, where you need to know the commit hash and cherry-pick.
  • merge — you get a nice UI of the diff and can resolve merge conflicts automatically or manually. You can also implement the pull request review in IntelliJ and complete everything there.
  • switch/checkout branches.
  • pull/push — using keyboard shortcuts.
  • cherry-pick — is sometimes needed to avoid code conflicts. I wouldn’t even know how to do that on the command line.

Rebase in 4, 3, 2, 1…

Marco likes keyboard shortcuts and spends time mastering, learning, and customizing them. Over the years, he’s configured his own collection, including a custom combo to rebase a branch into master:

  1. Ctrl (opens the git branches view and switches to the previous branch you were on before, which is usually master)
  2. Alt P (to do a git pull)
  3. Ctrl
  4. Alt W

Alternatively, he uses Alt F to fetch, skipping steps 1–3 and just hitting Alt F followed by Alt W.

Other frequent keyboard shortcuts he uses include:

  1. Alt Numpad-8 to annotate (when you feel like git blame).
  2. Alt Numpad-5 to compare with another branch.
  3. Ctrl Alt Numpad-5 to show the history of the current branch.

Get in the habit of Changelists

Furthermore, some things are almost impossible on the command line. “I was working with a portfolio company where I couldn’t directly access their libraries for security reasons. The solution was to manage versions using my IDE: I created two changelists, letting IntelliJ track the changes to the working tree and handle the commits”.

Marco wouldn’t be able to do that otherwise because there’s no direct CLI equivalent to changelistsIntelliJ’s replacement for Git’s Staging area is like git stash on steroids allowing you to complete intricate tasks, like commit of specific lines.

“People are so used to the command line that they might think that using alternative methods is lazy, but it can also be a personal preference, a matter of taste. As I see it, brilliant people wrote this extension or feature, and I trust their decisions. For me, it opened a whole new world of convenience. It’s not an ideological choice; it’s about finding a better, easier way of doing things”.

See it in action

Want to try it yourself? Here are four screencasts featuring Marco’s common workflows, including his keyboard combos:

Git rebasing using JetBrains IntelliJ IDEA

Switching Git branches in JetBrains IntelliJ IDEA

Git cherry picking in JetBrains IntelliJ IDEA

Changelist is JetBrains IntelliJ IDEA’s replacement for Git staging