Git & Version Control — Full Course
From your first commit to pull requests and resolving conflicts — the essential tool behind every real software project.
From your first commit to pull requests and resolving conflicts — the essential tool behind every real software project.
Git is a version control system created by Linus Torvalds (also the creator of Linux) in 2005. Its job is simple to describe and enormously useful in practice: it tracks every change made to a project’s files over time, lets multiple people work on the same codebase without overwriting each other’s work, and lets you […]
The three-stage mental model Git has three areas worth understanding from day one: your working directory (the actual files you are editing), the staging area (changes you have marked as ready to be committed), and the repository (the permanent, committed history). Understanding this three-step flow is the single biggest thing that makes Git commands click […]
What a branch actually is A branch is simply a movable pointer to a specific commit — creating one is instant and cheap, which is exactly why Git-based workflows encourage creating a new branch for every feature or fix, rather than working directly on the main line of history. git branch feature-login # create a […]
Everything so far has lived entirely on your own computer. A remote is a copy of the repository hosted elsewhere — most commonly on GitHub, GitLab, or Bitbucket — that lets you back up your work and collaborate with other people. Connecting to a remote git remote add origin https://github.com/yourname/your-repo.gitngit remote -v # confirm it […]
A merge conflict happens when two branches change the exact same lines of the exact same file in different ways, and Git genuinely cannot guess which version you want. This is normal, expected, and nothing to panic about — every developer runs into conflicts regularly. What a conflict looks like <<<<<<< HEADnconst greeting = “Hello, […]
Undoing uncommitted changes git checkout — index.html # discard uncommitted changes to one filengit restore index.html # the newer, equivalent command This throws away changes you have made but not yet committed, restoring the file to how it looked at your last commit — useful when you have gone down a wrong path and just […]
Pull requests A pull request (called a “merge request” on GitLab) is how most real teams actually merge code — instead of merging directly on your own machine, you push your branch to the remote and open a pull request asking for it to be reviewed and merged into main. This gives teammates a chance […]