GitHub is a platform where developers and teams around the world collaborate on code projects, track changes, and manage software development—all in one place.
At its core, GitHub is:Git is a version control system created by Linus Torvalds (yep, the same guy behind Linux), whereas Github is a cloud-based platform that hosts Git repositories.
git --version
You should see something like `git version 2.xx.x`.
git config --global user.name "Your Name"
git config --global user.email "youremail@example.com"
mkdir my-first-repo
cd my-first-repo
✅ Initialize it as a Git repo:
git init
This creates a .git directory — the local database where Git tracks everything.
echo "# My First Repo" > README.md
git status
✅ Stage your file:
git add README.md
✅ Or stage everything at once:
git add .
git commit -m "Initial commit: add README"
https://github.com/yourusername/my-first-repo.git
✅ Add it as a remote:
git remote add origin https://github.com/yourusername/my-first-repo.git
✅ Push your branch (`main` or `master` depending on your Git version):
git branch -M main # sets branch name to main
git push -u origin main
git checkout -b feature1
This creates the branch and switches to it.
git add .
✅ Commit them:
git commit -m "Add feature 1"
git checkout main
✅ Return to your feature branch:
git checkout feature1
git checkout main
✅ Merge feature1 into main:
git merge feature1
💡 If there are conflicts, Git will tell you to resolve them manually.
git push
git clone https://github.com/yourusername/their-repo.git
cd their-repo
✅ Create a branch for your changes:
git checkout -b fix-issue-42
✅ Make changes, stage, commit:
git add .
git commit -m "Fix issue #42: correct typo"
✅ Push the branch to your fork on GitHub:
git push origin fix-issue-42
✅ On GitHub, go to your fork and you’ll see a Compare & pull request button.
Click it to submit your PR.
git log
✅ Compact one-line log:
git log --oneline
✅ View log with graphical branch history:
git log --oneline --graph --all
>>>>>> ======= <<<<<<
✅ Edit the files manually to keep what you want, remove the conflict markers, then:
git add conflictedfile.txt
git commit
git branch
✅ Delete a branch (after merging):
git branch -d feature1
✅ Pull latest changes from origin:
git pull
✅ See remote branches:
git remote -v
My advice is to commit your code often! If you lose power, your battery dies or you accidently erase hours of coding, you'll be glad you took my advice and committed your code to your remote repo.
Git & Github Crash Course 2025 Traversy Media: 49 min
Github for Beginners 2025 Corbin Brown: 10min
Git, Github and Github Desktop 2023 Coder Coder: 22 min