GitHub basics
Ever lost a good version of your work? Git and GitHub fix that. Git is a tool on your computer that records the history of your files.
Chapters
- 0:00Introduction
- 0:05Two names: Git and GitHub
- 0:16The folder: A repository
- 0:28Get a copy: Clone it down
- 0:37The daily loop: Change, then save
- 0:47Try it: Your first commit
- 0:55Share it: Push and pull
- 1:04Good habits: Write for later
- 1:14Stay safe: Keep secrets out
- 1:28From scratch: Start a new one
- 1:38Look back: See the history
- 1:47Wrap up
Read the transcript
Introduction
Ever lost a good version of your work? Git and GitHub fix that.
Two names: Git and GitHub
Git is a tool on your computer that records the history of your files. GitHub is a website that hosts that history, so you can back it up and work with others.
The folder: A repository
A project lives in a repository, or repo for short. It holds your files, every saved version of them, and usually a read me file that explains the project.
Get a copy: Clone it down
To get a copy onto your machine, clone it. Copy the address from the green Code button on GitHub, then move into the new folder.
git clone https://github.com/you/project.git
cd projectThe daily loop: Change, then save
Everyday work is a short loop. Edit your files. Add the changes you want to keep. Commit them, with a message saying what changed.
Try it: Your first commit
Git status shows what has changed. Git add picks a file. Git commit saves the snapshot with your message.
git status
git add README.md
git commit -m "Explain how to install"Share it: Push and pull
A commit stays on your computer until you share it. Git push sends your commits to GitHub. Git pull brings down what others have added.
Good habits: Write for later
A few habits pay off quickly. Commit small, related changes together. Write messages that say why. And pull before you start new work.
Stay safe: Keep secrets out
Never commit passwords or keys. List private files in a file called git ignore. Check whether a repository is public or private. If a key does get pushed, revoke it. Deleting the line is not enough.
From scratch: Start a new one
Already have a folder of work? Make an empty repository on GitHub. Turn your folder into a Git repository, then point it at GitHub and push.
git init -b main
git add . && git commit -m "First version"
git remote add origin \
https://github.com/you/project.git
git push -u origin mainLook back: See the history
Your history is easy to read. Git log lists the commits, newest first. Git diff shows what you've changed since the last one.
git log --oneline
git diffWrap up
That's the core: clone, edit, add, commit, push.
Sources
- docs.github.com/en/get-started/start-your-journey/about-github-and-git
- docs.github.com/en/repositories/creating-and-managing-repositories/about-repositories
- docs.github.com/en/repositories/creating-and-managing-repositories/cloning-a-repository
- docs.github.com/en/get-started/git-basics/ignoring-files
- git-scm.com/docs/gittutorial
- docs.github.com/en/migrations/importing-source-code/using-the-command-line-to-import-source-code/adding-locally-hosted-code-to-github
More lessons
- Docker intermediate 2:26
- Docker advanced 2:44
- Docker networking 2:28
- GitHub intermediate 1:57
- GitHub advanced 1:59
- AI coding agents 1:18