Git Course 0%

Every task: Terminal, VS Code, IntelliJ, GitLab, GitHub

Intermediate ≈ 12 min

What you will learn

  • Where every everyday task lives in each of the five tools
  • Which tasks exist in only some of them
  • Which tool is genuinely better for which job

After this lesson you can

  • I can follow an instruction written for any tool, using the one I have open

Why this matters

Colleagues give instructions in whatever tool they use. Documentation is written in commands. This page is the translation between all five, and it is the one to keep open for the first month.

Setting up

Task Terminal VS Code IntelliJ IDEA GitLab GitHub
Set your identity git config --global user.email Terminal Terminal Verify it under Edit profile → Emails Verify it under Settings → Emails
Create a repository git init Initialize Repository Enable Version Control Integration New project New repository
Clone git clone <url> Git: Clone Clone Repository Code button Code button
Add a remote git remote add origin <url> Terminal PushDefine remote Shown on the empty project Shown on the empty repo

Every day

Task Terminal VS Code IntelliJ IDEA GitLab GitHub
See what changed git status The Source Control view The Commit window
Read a diff git diff Click the file Click the file Changes tab Files changed tab
Stage a file git add <file> + on the file Add to VCS
Stage part of a file git add -p Stage Selected Ranges The gutter marker
Unstage git restore --staged <f> on the file Uncheck it
Discard an edit git restore <f> discard Rollback
Commit git commit -m "…" Commit Commit (⌘K) The web editor The web editor
Amend git commit --amend Commit Staged (Amend) The Amend checkbox
Push git push Sync Changes Push (⇧⌘K)
Pull git pull Sync Changes Update Project (⌘T)
Fetch only git fetch Git: Fetch The VCS widget's fetch icon
Park work git stash … → Stash Stash or Shelve

Branches

Task Terminal VS Code IntelliJ IDEA GitLab GitHub
List branches git branch -a The Status Bar menu The VCS widget Code → Branches Branches
Create git switch -c <name> Create new branch… New Branch New branch New branch
Switch git switch <name> Status Bar → the branch Checkout
Publish git push -u origin <name> Publish Branch Push (⇧⌘K)
Compare with main git log --oneline main..HEAD Git: Compare With… Compare with Current Compare revisions Compare
Merge git merge <name> Git: Merge Branch… Merge into Current The merge button The merge button
Rebase git rebase <name> Git: Rebase Branch… Rebase Current onto Selected Rebase on the merge request Update branch → Rebase
Delete local git branch -d <name> Git: Delete Branch… Delete
Delete remote git push origin --delete <name> Terminal Delete on the remote branch Delete source branch Delete branch

History and investigation

Task Terminal VS Code IntelliJ IDEA GitLab GitHub
Read the history git log --oneline --graph Source Control Graph The Log tab Code → Commits The commit list
One file's history git log -- <f> The Timeline view Show History History History
Who changed this line git blame <f> GitLens Annotate with Git Blame Blame Blame
Search commits git log --grep="…" The graph's filter The Log's search box The commit search The commit search
Show one commit git show <hash> Click it in the graph Click it in the Log Its commit page Its commit page

Undo and recovery

Task Terminal VS Code IntelliJ IDEA GitLab GitHub
Undo the last commit, keep changes git reset --soft HEAD~1 Undo Last Commit Undo Commit
Move the branch back git reset <mode> <target> Terminal Reset Current Branch to Here…
Undo a pushed commit git revert <hash> Revert Commit Revert Commit Revert Revert
Copy a commit elsewhere git cherry-pick <hash> Cherry Pick Commit Cherry-Pick Cherry-pick Local only
Escape a merge git merge --abort Git: Abort Merge Abort Merge
Find a lost commit git reflog Terminal only Terminal only Only if it was pushed Only if it was pushed
Recover uncommitted work Nothing The Timeline Local History

Conflicts

Task Terminal VS Code IntelliJ IDEA GitLab GitHub
See which files conflict git status Merge Changes The conflicts dialog On the merge request On the pull request
Resolve inline Edit the markers Accept Current / Incoming Accept Yours / Theirs Web editor, simple cases Web editor, simple cases
Resolve with all three versions merge.conflictstyle zdiff3 Resolve in Merge Editor Merge → three panes
Finish git add then git commit Complete Merge, commit Accept and Finish, commit Merge it Merge it

Proposing and reviewing

Task Terminal VS Code IntelliJ IDEA GitLab GitHub
Open a merge or pull request glab mr create / gh pr create The extension The tool window New merge request New pull request
Review a change git switch <branch> and read The extension's diff The tool window's diff Changes tab Files changed tab
Suggest wording A suggestion fence A suggestion fence Insert suggestion The suggestion button
Approve The extension The tool window Approve Approve
Merge The extension The tool window The merge button The merge button
See why the merge is blocked Partly Partly The merge box The merge box

Which tool for which job

Honest recommendations after all of that:

Job Best tool Why
Staging parts of a file VS Code or IntelliJ Selecting lines beats an interactive prompt
Resolving a conflict that needs judgement IntelliJ The base pane shows what both sides changed
Reading history with filters IntelliJ The Log's filters are the best of the five
Recovering anything The terminal git reflog exists nowhere else
Recovering uncommitted work IntelliJ, then VS Code Local History and the Timeline; Git has nothing
Understanding what happened The terminal Commands say exactly what they do
Reviewing with context Either IDE The whole file, not six lines
Deciding whether it can merge The platform The merge box is authoritative
Following someone's instructions The terminal Instructions are written in commands

How to do it

The commands in this table are the whole of everyday Git. The cheat sheets hold them in a printable form.

Common mistakes

  • Assuming a tool cannot do something because you have not found it. Search the palette or Find Action first.
  • Assuming a tool can do everything. The reflog is not in either IDE.
  • Insisting on one tool. The right answer is usually whichever is already open, except for recovery.
  • Following an instruction literally in the wrong tool. "Discard" and "unstage" are different commands, and the words are close.

Try it yourself

Goal: do the same task three ways.

  1. Pick one task from the table: staging part of a file is a good one.
  2. Do it in the terminal with git add -p.
  3. Undo, and do it in VS Code with Stage Selected Ranges.
  4. Undo, and do it in IntelliJ from the gutter marker, if you have it installed.
  5. Note which felt fastest, and which you would send to a colleague as an instruction.

Expected result: the same staged change three ways, and a personal answer to which tool you would reach for.

Show solution

Step 5 usually produces two different answers, and that is the point: the fastest tool for doing something is often not the clearest one for describing it. Commands are the shared language, which is why every lesson in this course names them even when it is teaching a button.

Check yourself

1. Which task exists only in the terminal?
2. Which tool can recover work that was never committed?
3. A colleague's instructions are written as commands but you work in an IDE. What is the reliable route?

Key terms

Commit Branch Merge request (MR) Stash