In 30 minutes you'll make commits, push them to GitHub, and open a pull request.
Each dot is a commit; the letter is who made it (Anna, Ben, Setup). Tags show where a branch points: 💻 on your laptop, ☁️ on GitHub.
A commit is a save point. Push uploads your save points to GitHub; pull downloads everyone else's.
Tip
Golden rule: run git status after every step. It tells you what's going on.
Important
Before the workshop: install and configure git with git-setup.md. If you did, skip the git config lines below and start at git clone.
Tip
If you want to keep your email private, check https://github.com/settings/emails and use the email provided there instead of your private email. It would look something like 141524111+Arseni10Lk@users.noreply.github.com
git config --global user.name "Your Name"
git config --global user.email "you@example.com"
git config --global pull.rebase true
git clone https://github.com/knnmelprop/git-workshop.git
cd git-workshop
git log --oneline
- Create the file
members/<your-name>.md(lowercase, no spaces, e.g.members/anna-kowalska.md). Copy the format frommembers/example.md. git status: your file is listed as untracked (red).git add members/<your-name>.mdgit status: your file is now staged (green).git commit -m "Add <your name>"git log --oneline: your commit is at the top.
git push- Rejected with "fetch first"? Someone pushed before you. Run
git pull, thengit pushagain. - Open the repo on GitHub and find your file in
members/.
Why a push gets rejected: everyone pushes to the same main. If a classmate got there first, your laptop is missing their commit.
- Create a branch:
git switch -c <your-name>-update - Add a line to your file:
What I'd use git for: ... git diff: see exactly what you changed.git add members/<your-name>.mdandgit commit -m "Update <your name>"git push -u origin <your-name>-update- Open the link git printed (or click Compare & pull request on the repo page) and create the pull request.
- Accept your neighbor's PR: open their PR, go to Files changed → Review changes, write a short comment, choose Approve, and submit.
- Once your PR is approved, click Merge pull request → Confirm merge.
- Back in the terminal:
Your change is now on main.
git switch main git pull
| Command | What it does |
|---|---|
git clone <url> |
Download a repository |
git status |
Show what changed and what's staged |
git add <file> |
Stage a file for the next commit |
git commit -m "msg" |
Save staged changes as a commit |
git log --oneline |
Show commit history |
git diff |
Show unstaged changes |
git push |
Upload your commits to GitHub |
git pull |
Download others' commits |
git switch -c <name> |
Create and switch to a new branch |
git switch main |
Go back to main |
- "not a git repository": you're in the wrong folder. Run
cd git-workshop. - "nothing added to commit": you forgot
git add. - A weird editor opened (vim): type
:wqand press Enter. - Asked for a password when pushing: GitHub doesn't accept passwords. Ask a helper.
git switchnot recognized: your git is old. Usegit checkout -b <name>instead.- Push rejected:
git pull, thengit push.