Git Foundations / Start Here

Install Git and check your setup

Lesson 2 of 33. Open to read. No account needed.

What This Lesson Sets Up

By the end of this lesson you will have Git installed, a terminal that runs the course's commands, and an empty practice folder for the exercises. You will also check that your Git version is new enough, because some commands in this course do not exist in older versions.

Choose Your Terminal

The exercises are written for one kind of terminal program, called a POSIX shell, so the same commands work on every system:

  • Windows: use Git Bash, which is installed together with Git for Windows. Command Prompt and PowerShell are different shells, and some exercise commands will not work in them.
  • macOS: use the Terminal app, in Applications > Utilities.
  • Linux: use your distribution's terminal.

When a lesson says "in the terminal", it means this program.

Install Git

Use the official installation route for your system, listed on the Git website's install page.

Windows. Download Git for Windows from the install page and run the installer. It asks several questions; the default answers work for this course, because you will set the important choices yourself in the next lesson. If you use the Windows package manager instead, the install page gives this command:

winget install --id Git.Git -e --source winget

macOS. Choose one route:

  • If you use Homebrew, run brew install git.
  • Apple's Xcode Command Line Tools include Git: run xcode-select --install. This version can be older than the current release, so check it below.
  • If you use MacPorts, run sudo port install git.

Linux. Use your distribution's package manager, for example:

sudo apt-get install git    # Debian and Ubuntu
sudo dnf install git        # Fedora

sudo runs a command with administrator rights and asks for your password. On a work or school computer you may need an administrator to install software. If the package manager reports that it cannot find the package, refresh its package list first, for example with sudo apt-get update on Debian or Ubuntu, then run the install command again. Distribution packages can lag behind the newest Git release; the version check below tells you whether yours is new enough.

Check Your Git Version

Open a new terminal window after installing, so it picks up the new program. Then run:

git --version

Illustrative output:

git version 2.56.0

The number on your computer may differ. On Windows it may be followed by extra text such as .windows.2. This course needs Git 2.28 or later, because version 2.28 added the option for naming a new repository's first branch, which the course uses from the start. The course was planned against Git 2.56.0, the latest release when it was written.

Compare version numbers part by part, not as decimals. In 2.56.0, the first part is 2 and the second part is 56. The second part is a whole number, so 2.9 is older than 2.28, because 9 is less than 28. Any version from 2.28.0 upwards, such as 2.39.5 or 2.56.0, is fine.

If your version is older than 2.28, update it through the same route you used to install it, or choose a newer route on the install page.

Terminal Commands the Exercises Use

The exercises rely on a few commands besides Git. ~ means your home folder.

CommandWhat it doesExample
pwdPrints the folder you are inpwd
lsLists what is in the current folderls
cdMoves into a folder; cd .. moves up one levelcd ~/git-practice
mkdir -pCreates a folder, and any missing parent folders; no error if it already existsmkdir -p ~/git-practice
catPrints a file's contentscat notes.txt

Setup commands also use printf with > to write files, so everyone starts with identical content:

printf 'First line\nSecond line\n' > notes.txt

printf prints the text between the quotes, where \n means "start a new line". The > sends that text into the file named after it, replacing the file's contents if it already exists. The command prints nothing on screen.

Cleanup uses rm -rf, which deletes a folder and everything in it without asking for confirmation and without a recycle bin. The exercises therefore always move to ~/git-practice first, list its contents and then remove one named exercise folder. Never run rm -rf with a path you have not checked.

Exercise: Check Your Setup

This exercise confirms that Git and your terminal work and creates the practice folder used by every later exercise. It creates one file in a temporary exercise folder and then removes that folder.

Starting state: Git is installed and a terminal is open.

  1. Check Git:

    git --version
    

    You should see a version of 2.28 or later.

  2. Create and enter an exercise folder:

    mkdir -p ~/git-practice/check-setup
    cd ~/git-practice/check-setup
    pwd
    

    Illustrative output; the beginning of the path depends on your system and user name, but it should end with git-practice/check-setup:

    /home/asha/git-practice/check-setup
    

    On macOS the path starts with /Users/; in Git Bash it starts with /c/Users/.

  3. Write a file and read it back:

    printf 'Git practice works.\n' > hello.txt
    ls
    cat hello.txt
    

    Illustrative output:

    hello.txt
    Git practice works.
    
  4. Clean up. Move to the practice folder, check what is there, remove only the exercise folder, then list again:

    cd ~/git-practice
    ls
    rm -rf check-setup
    ls
    

    The first ls shows check-setup; the second shows nothing. Keep the git-practice folder itself: later exercises use it.

Success: Git reports 2.28 or later; pwd ends with git-practice/check-setup; cat prints the line you wrote; and after cleanup, check-setup is gone while ~/git-practice remains.

If something differs:

What you seeLikely causeNext step
git: command not foundGit is not installed, or this terminal opened before installingInstall Git, then open a new terminal; on Windows, use Git Bash
'git' is not recognized as an internal or external commandYou are in Command Prompt or PowerShellOpen Git Bash instead
A version older than 2.28An old installationUpdate Git, then check again
No such file or directory after cdThe mkdir step did not run, or there is a typoRun the mkdir -p line again, then cd
cat: hello.txt: No such file or directoryThe file was written in a different folderRun pwd, return to the exercise folder and rerun the printf line

Independent task: without copying the commands above, create a folder called scratch inside ~/git-practice, write a file in it containing your first name, print the file, then remove the scratch folder and confirm it is gone. Compare your commands with the answer below.

Check Your Understanding

Two learners run git --version. One sees git: command not found. The other sees git version 2.25.1. What is wrong in each case, and what should each do? And which is newer: Git 2.9.5 or Git 2.28.0?

Answer and Reasoning

Independent task

One correct sequence:

mkdir -p ~/git-practice/scratch
cd ~/git-practice/scratch
printf 'Asha\n' > name.txt
cat name.txt
cd ~/git-practice
ls
rm -rf scratch
ls

Any file name works. What matters is that you wrote and printed the file inside scratch, moved out to ~/git-practice before deleting, and checked that scratch appeared before removal and was absent after it.

Understanding check

The first learner's terminal cannot find Git: it is not installed, or the terminal was opened before installation, or (on Windows) the learner is not in Git Bash. Installing Git and opening a new Git Bash or terminal window fixes it.

The second learner has Git, but version 2.25.1 is older than the 2.28 minimum, so commands that name a new repository's first branch will not work. Updating Git fixes it.

Git 2.28.0 is newer. Compare the second parts as whole numbers: 28 is greater than 9.

References

Study this course with an account

Course access adds revision notes, the Quick Reference, saved progress, bookmarks and your own notes.

INR 99 plus 18% GST. 90 days of online access. No auto-renewal.

See course access

This website is operated by VECTAMETRIC EDTECH (OPC) PRIVATE LIMITED, operating as Vectametric.

Corporate Identity Number (CIN): U85499KA2026OPC229822. GSTIN: 29AAMCV8281D1ZS. Registered office: RS NO/38/2A/1 BASTAND, ROAD MAHANTESH NAGAR, Ramdurg, Ramdurg, Belgaum- 591123, Karnataka.

Queries and grievances: Prajval Honnungar, Grievance Officer and Data Protection Contact.

Telephone: +91 94800 09310. Support: support@vectametric.com. Grievances: support@vectametric.com.

Copyright 2026 VECTAMETRIC EDTECH (OPC) PRIVATE LIMITED. All rights reserved.

Vectametric home · Roadmaps · Vecta IT Exams · Vecta Government Exams · Vecta Banking & Finance Exams · Vecta Entrance Exams · About us · Contact · Privacy Policy · Terms and Conditions · No-Refund Policy