Git Basics: Version Control from Zero
Learn Git from scratch by practicing in a terminal inside your browser: commits, history, undoing changes, branches, merge, conflicts, rebase, GitHub, pull requests and team best practices.
Kurs-Badge Git Basics Schließe alle Lektionen ab, um es zu bekommen.
Kursinhalt
Getting started
4 LektionenWhat is Git?
What version control is, how Git was born, how it differs from GitHub, and why virtually every software team uses it.
Installing and configuring Git
How to install Git on Windows, macOS and Linux, check the version, and do the initial setup: name, email, main branch and editor.
The terminal in 15 minutes
The basic terminal commands you need to use Git: moving between folders, listing, creating, reading and editing files.
Your first repository
Create a repository with git init, understand what the .git folder is, and read what git status tells you.
The basic cycle
5 LektionenGit's three areas
Working directory, staging area and repository: the mental model that explains every Git command and the lifecycle of a file.
Saving changes: git add and git commit
Stage files with git add (one, several or all), save commits with git commit -m, the -a shortcut, and how to read Git's response.
Good commit messages
How to write clear commit messages, how often to commit, and how to fix the last commit with git commit --amend.
Ignoring files with .gitignore
Which files should never go into a repository, how to write a .gitignore with patterns, and what to do if you already committed something you should have ignored.
Seeing what changed: git diff
Read the output of git diff, compare the working directory, the staging area and commits, and review your changes before saving them.
History and undoing changes
4 LektionenExploring the history
git log and its most useful options, git show to inspect a commit, what HEAD is, how to refer to earlier commits with ~ and ^, and how to travel to an old version.
Discarding changes: restore, rm and mv
Undo changes you haven't saved yet with git restore, take files out of the staging area, recover deleted files, and delete or rename files with Git.
Undoing commits: reset and revert
The two ways to undo commits: git revert creates a commit that cancels them and git reset moves the branch back (--soft, --mixed and --hard). When to use each one.
Setting work aside: git stash
Put changes aside without committing using git stash to deal with another task, and get them back later with pop or apply.
Branches
4 LektionenBranches: branch and switch
What a branch is, how to create one, switch between branches, list, rename and delete them, and why branches are so cheap in Git.
Merging branches
Integrate one branch's work into another with git merge: fast-forward, three-way merge commit, the --no-ff option, and cleaning up finished branches.
Resolving conflicts
Why merge conflicts happen, how to read the <<<<<<< ======= >>>>>>> markers, resolve them step by step or cancel the merge, and how to avoid them.
Rebase and cherry-pick
Replay your commits on top of another branch with git rebase for a linear history, resolve conflicts during a rebase, copy a single commit with cherry-pick, and when NOT to rebase.
Working as a team
3 LektionenRemote repositories and git push
Create a repository on GitHub or GitLab, connect it with git remote add, upload your commits with git push, understand the upstream, and authenticate with SSH or a token.
Working with others: clone, fetch and pull
Copy a repository with git clone, bring in your team's changes with git fetch and git pull, and what to do when your push is rejected because the remote has new work.
Pull requests and code review
The collaborative workflow on GitHub and GitLab: branch, push, open a pull request, review code, address comments, merge and clean up. Also how to contribute to other people's projects with a fork.
Best practices
2 LektionenTags and versions
Mark versions with git tag, the difference between lightweight and annotated tags, how to push them to the remote, and how to number versions with semantic versioning (SemVer).
Conventional commits and workflows
The Conventional Commits convention, the most common workflows (GitHub Flow, Git Flow and trunk-based), a list of best practices, and a final project to review the whole course.