Braids - Intro to Git
Goal: introduce Git as an archiving practice, then do a little branch-based website exercise published live.
Archiving analogy:
@karl: should we add some apps for working with git here? VSC + Git lens, Github desktop, Sourcetree etc
Check first:
git --versionIf missing:
Minimum requirement: you can run git in a terminal.
This is why Git feels "archival":
Create a repository in the current folder. Use this when you are creating and working on your own projects.
git initCreates a .git/ directory containing history + metadata.
For the exercise we will use git clone instead of git init.
Cloen (copy) a repository in the current folder.
git clone https://git.hackersanddesigners.nl/hrk/braids <destination>
Downloads a repo from the web, complete with the full commit history and all changes.
git statusShows:
Stage files for the next commit.
git add index.html git add assets/
Stage everything (use carefully):
git add .
Staging is curatorial: select what belongs together.
git commit -m "Added name to my page"
Good commit message pattern:
git log --oneline --graph
Gives a quick "finding aid" of earlier commits. Press 'q' to exit.
List branches:
git branchCreate a branch:
git branch people/yourname
Switch to branch:
git checkout people/yourname
Shortcut (create + switch):
git checkout -b people/yourname
Branches are parallel dossiers: safe space for changes.
Push your branch to the server:
git push -u origin people/yourname
Pull updates from server:
git pullDuring the exercise you mostly push your branch. Pull is mainly for getting new changes on main (if needed).
Remove a tracked file and stage the removal:
git rm old.html git commit -m "Remove old page"
For this workshop you probably will not need it.
You will: - create an account - clone via HTTPS - push your branch
Share your username with us so we can add you as a collaborator
Rules for today:
Resources:
You will build a (deliberately) simple page:
Workflow loop:
clone -> branch -> edit -> status -> add -> commit -> push -> view -> iterate
cd to a logical location in your computer, then:
git clone https://git.hackersanddesigners.nl/hrk/braids cd braids
If everything went well, check the repo with:
git status git branch
The first time you checkout from https://git.hackersanddesigners.nl the server will ask you for credentials. These will be remembered, so only once.
Choose a slug: lowercase, no spaces. This can be your name or an alias. Example: change people/<your-slug> in the command below to people/alex. From here on out replace <your-slug> with your chosen name.
git checkout -b people/<your-slug>
Confirm:
git statusEdit the root index.html (and optionally style.css, assets/).
Make a visible change first:
Then check changes:
git diff git status
git add index.html git commit -m "Customize profile page for <your-slug>"
If you added assets:
git add assets/ git commit -m "Add assets for <your-slug>"
Small commits win. One change = one deposit.
git push -u origin people/<your-slug>
(Again, change <your-slug>!)
If prompted for credentials, use your Forgejo login method.
Open the gallery:
Find your card:
Iterate:
edit -> status -> add -> commit -> push -> refresh
Wrong branch:
git branch git checkout people/<your-slug>
Nothing staged:
git status git add index.html
Push rejected (main protected):
Auth issues:
Bad:
Better:
Rule: message should still make sense in 6 months.
Learn more:
End: remind participants their branches will be removed after the workshop.