Git Course 0%

Verify and update

Beginner Git CLI ≈ 5 min

What you will learn

  • How to find which Git executable the terminal uses
  • What to do when two versions are installed
  • How to update on each operating system

After this lesson you can

  • I can tell a colleague my exact Git version and where it is installed

Why this matters

"Which Git?" sounds pedantic until VS Code uses one version and your terminal another, or a colleague's command fails on your older release. Two commands settle it.

Which Git is running

Terminal
$ git --version
git version 2.50.1 (Apple Git-155)
Terminal
$ which git
/usr/bin/git

which git prints the file the terminal runs when you type git. Typical locations:

System Location Comes from
macOS /usr/bin/git Apple's command line tools
macOS /opt/homebrew/bin/git (Apple silicon) or /usr/local/bin/git (Intel) Homebrew
Windows (Git Bash) /mingw64/bin/git Git for Windows, installed under C:\Program Files\Git
Linux /usr/bin/git the distribution's package

On Windows PowerShell the equivalent is Get-Command git, which shows C:\Program Files\Git\cmd\git.exe.

Two Gits on one machine

Common on macOS: Apple's Git in /usr/bin and a newer Homebrew Git. The terminal runs whichever comes first on its search path (echo $PATH shows the order; Homebrew normally puts itself first). Either version is fine for this course; the problem arises only when an IDE picks the other one and behaves slightly differently. Lesson 3.6 shows how to point VS Code and IntelliJ at the same file that which git prints.

Updating

System Command or action
macOS, Homebrew brew update && brew upgrade git
macOS, Apple tools Updates arrive with macOS updates; or xcode-select --install again after a major macOS upgrade
Windows git update-git-for-windows in Git Bash checks and installs the latest release; or rerun the installer from gitforwindows.org
Linux sudo apt upgrade git / sudo dnf upgrade git, or the distribution's updater

Updating Git never touches your repositories: the history lives in each project's .git folder and the format is stable across versions.

Common mistakes

  • Reading git: 'switch' is not a git command as a typo. It means Git is older than 2.23. Update.
  • Updating and still seeing the old version. The terminal remembers program locations; open a new terminal window. On macOS, check which git: Apple's Git may still be first on the path.
  • Assuming the IDE updated too. VS Code and IntelliJ use the executable they were pointed at; verify in lesson 3.6 after a big update.

Try it yourself

Goal: record your Git version and location for the next time someone asks.

  1. Run git --version and which git (Windows PowerShell: Get-Command git).
  2. Write both lines into ~/git-practice/notes/day-1.md (created in Lab 1) or any note.

Expected result: a version ≥ 2.23 and an absolute path.

Show solution

Typical macOS answer: git version 2.50.1 (Apple Git-155) and /usr/bin/git. If the path is under Homebrew, the version line has no (Apple Git-…) suffix. Both are fine.

Check yourself

1. git: 'restore' is not a git command most likely means…
2. After updating, git --version still shows the old number. First thing to try?

Key terms

Git