You will be able to
- Install and configure Git with your name, email, default editor and line-ending settings
- Create a repository and explain how the working directory, staging area and commit history relate
- Stage, commit, rename and remove files with clear commit messages
- Ignore unwanted files with .gitignore and check changes with status, diff and log
- Inspect project history with git show and git log, and find out what each commit contains
- Undo staged changes, discard local edits and restore deleted files
Good to know first
- Basic familiarity with using a terminal or command prompt
- Basic file and folder operations such as creating, editing and deleting files
- A computer where you can install software and a text editor such as VS Code
Syllabus
10 lessons and a final project
- 1
Why Git exists and how version control works Free
You will learn what a version control system is and why it beats keeping copies of a project in folders. You will also learn the difference between centralized and distributed systems and why Git is the most popular one.
2 exercises3 questions - 2
Installing Git and choosing a terminal or GUI Beyond Pass
You learn the three ways to work with Git (command line, a code editor's built-in source control, and a graphical app) and why this course leans on the command line. You also learn how to check whether Git is installed, which version you have, and where to download the latest one.
1 code4 build steps2 exercises4 questions - 3
Configuring your identity, editor and line endings Beyond Pass
You will learn how Git stores settings at three levels (system, global, local), and how to set your name, email, default editor and line-ending handling with git config. You will also see why core.autocrlf matters when people on Windows and macOS share a repository.
4 code5 build steps3 exercises3 questions - 4
Getting Help and Initializing Your First Repository Beyond Pass
You learn three ways to look up help for any Git command, then create a project folder and turn it into a Git repository with git init. You also see what the hidden .git folder is and why you must never delete it.
4 code6 build steps3 exercises4 questions - 5
The basic Git workflow: staging and committing changes Beyond Pass
You will learn the three places Git keeps your work (working directory, staging area, repository) and the everyday cycle of editing, adding and committing. You will also practise git status, git add, git commit -m and good commit-message habits.
2 code9 build steps3 exercises4 questions - 6
Committing shortcuts, removing and renaming files Beyond Pass
You will learn how to skip the staging area with git commit -am, and how to remove and rename files with git rm and git mv so that the working directory and staging area stay in sync. You will also see why deleting or renaming with plain Unix commands needs an extra git add step.
3 code6 build steps3 exercises3 questions - 7
Ignoring files and checking status Beyond Pass
You will learn how to tell Git to ignore files and folders with a .gitignore file, and why files Git already tracks are not ignored. You will also learn to read the short status output (git status -s) and to remove a folder from the staging area with git rm --cached -r.
2 code6 build steps4 exercises4 questions - 8
Comparing changes with git diff and VS Code Beyond Pass
You will learn how to read the output of git diff, which compares file versions, and how to use git diff --staged to review what will go into your next commit. You will also set up VS Code as Git's visual diff tool and use git difftool to compare files visually.
1 code3 exercises4 questions - 9
Browsing commit history with log, show and ls-tree Beyond Pass
You will learn how to list the commits in a Git repository with git log, inspect a single commit with git show, and look inside a snapshot with git ls-tree. Along the way you will see how commits, blobs and trees are the objects Git stores.
7 build steps4 exercises4 questions - 10
Undoing staged changes, edits and deletions with git restore Beyond Pass
You will learn how to undo things in Git with git restore. You will unstage a file, throw away edits, delete untracked files with git clean, and bring back a deleted file from an older commit.
5 code8 build steps3 exercises4 questions
Final project
Version-control a mini project with a full Git history
Set up a small project from scratch and use Git for its whole life. You will configure Git, make several well-described commits, ignore build files, inspect the history and recover from mistakes. At the end you will explain what Git stores at each step.
Its 7 tasks open with Beyond Pass.
Free preview · Lesson 1 in full
Why Git exists and how version control works
You will learn what a version control system is and why it beats keeping copies of a project in folders. You will also learn the difference between centralized and distributed systems and why Git is the most popular one.
Draw and write next to the video.
The idea
Git is a version control system: a tool that records the changes made to your code over time. The record is kept in a special database called a repository. Because of it, you can look back at your project's history and see who changed what, when and why. If you break something, you can go back to an earlier state.
Without a version control system, people often save copies of the whole project in folders such as 'project-final', 'project-final2' and so on. This is slow and does not scale. When several people work on the same project, it gets worse: you have to send the latest code around by email and merge the changes by hand. A version control system solves both problems: it tracks the history and lets people work together.
There are two kinds of version control systems. In a centralized system, every team member connects to one central server to get the latest code and to share changes. Subversion and Team Foundation Server are examples. The weakness is the single point of failure: if the server goes offline, nobody can collaborate or save snapshots of the project.
In a distributed system, every team member has a full copy of the project, including its history, on their own machine. You can save snapshots locally even when the central server is offline, and you can sync your work directly with others. Git and Mercurial are distributed systems.
Git is the most popular version control system in the world. It is free, open source, very fast and scalable. Operations such as branching and merging are slow and painful in older systems, but they are fast and cheap in Git. Over 90 percent of software projects use Git, so almost every software developer job asks for it.
Key points
- A version control system records changes to your code over time in a repository, so you can see the history and go back to earlier states. 0:12
- Copying project folders by hand is slow, does not scale, and makes teamwork by email and manual merging painful. 1:00
- Centralized systems rely on one server; if it goes offline, you cannot collaborate or save snapshots. 1:31
- Distributed systems like Git give every member a full copy with its history, so you can work and save snapshots offline. 2:00
- Git is free, open source, fast, scalable and has cheap branching and merging, which is why it is the industry standard. 2:31
Words to know
- Version control system
- A tool that records changes to files over time so you can track history and go back to earlier versions.
- Repository
- The special database where a version control system stores a project's history.
- Centralized system
- A version control system where everyone connects to one central server to share and get code.
- Distributed system
- A version control system where every team member has a full copy of the project and its history.
- Single point of failure
- One part whose failure stops the whole system, such as a central server going offline.
Watch out
- Keeping copies like project-final-v2 is not version control: it is slow, wastes space and makes merging changes by hand very hard. 1:00
- Distributed does not mean there is no server; it means every copy holds the full history, so no single machine is essential. 1:31
- Git is not the only distributed system; Mercurial is another, and older systems like Subversion are centralized. 2:31
Practice
In your own words, explain why a team working on a project with a centralized system can be stuck when the server goes down, and how a distributed system avoids this.
Solution
- In a centralized system, all work goes through one server.
- If the server is offline, nobody can get the latest code, share changes or save snapshots.
- In a distributed system, every member has a full copy with history on their own machine.
- So they can keep saving snapshots locally and sync later when the server, or another teammate, is available.
A centralized system depends on one server, so when it is offline the team is blocked. A distributed system gives everyone a full copy with history, so they can keep working and save snapshots locally, then sync later.
Write down three problems you would have if you tracked a school essay by saving copies named essay1, essay2, essay_final, essay_final_real. Then say which Git feature from this chapter would solve each one.
Solution
- Problem 1: you cannot easily tell which copy has which change; Git's history shows who changed what and when.
- Problem 2: if a change breaks the essay, you must find the right copy; Git lets you revert to an earlier state.
- Problem 3: if you share with a friend, you must merge changes by hand; Git tracks changes so collaboration is easier.
Three problems: unclear history, hard recovery, and manual merging. Git solves them with its recorded history, reverting to earlier states, and tracked collaboration.
On your scratchpad
On a sheet of paper, draw two diagrams: one centralized (several people connected to one server in the middle) and one distributed (several people, each with their own copy of the project). Mark where the single point of failure is.
Quiz
What is a repository in version control?
- A folder that holds only the latest version of your files
- The special database where the system stores the project's history
- A website where you upload your code for others to download
- A list of your team members
Show the answer
B. The special database where the system stores the project's history · A repository is the database that records the project's changes over time.
0:25 watch the momentWhy is a centralized system risky?
- It is always slower than copying folders
- It has a single point of failure: if the server is offline, you cannot collaborate or save snapshots
- It cannot record history
- It cannot be used by more than one person
Show the answer
B. It has a single point of failure: if the server is offline, you cannot collaborate or save snapshots · The central server is one point whose failure blocks the whole team.
1:25 watch the momentWhich of these is a distributed version control system?
- Subversion
- Team Foundation Server
- Git
- A folder named project-final
Show the answer
C. Git · Git and Mercurial are distributed. Subversion and TFS are centralized.
1:45 watch the moment
Lessons 2–10 and the final project
They open with Beyond Pass: every lesson of every course, in full. One payment: $14.99 for 90 days or $29 for a year. No subscription.
Made by Beyond from the video “Git Tutorial for Beginners: Learn Git in 1 Hour” by Programming with Mosh. The video plays in YouTube's own player. Watch it on YouTube · All lessons
