Guide · 5 of 8
Save it on GitHub
Right now your project lives on one computer. By the end of this page it is also on GitHub, with every snapshot you saved. You can get it back from any machine, show it to anyone, and in the next chapter put it online.
What GitHub is
GitHub is a website that keeps copies of git projects. You push your snapshots up to it, and it shows your code and its history in the browser.
You need
- git and a terminal, from chapter 1.
- A project folder with something in it. The meal picker from chapter 4 is perfect.
Set up, once
-
Make an account at github.com/signup. The free plan is enough. Public and private repos are both free.
You should see: your GitHub home page, with your username in the top corner.
-
Get a no-reply email address. Every commit carries an email, and on a public repo anyone can read it. GitHub gives you a private stand-in. On github.com go to Settings → Emails and copy the address that ends in
noreply.github.com. -
Tell git who you are and install
gh, GitHub's own command-line tool. Hand this to the agent. Put your own name and the no-reply address in place of the examples:Set my git name to "Your Name" and my git email to you@example.com for all projects. Then install gh, GitHub's command-line tool, on this computer. Don't log in, I'll do that myself.
You should see: it runs two config commands and an install, asking you to approve each. At the end,
gh --versionprints a version.By hand, if you want to see what it ran
Your name goes on every commit you make:
git config --global user.name "Your Name"Then your email. Paste the no-reply address in place of the example.
git config --global user.email "you@example.com"You should see: nothing printed. That means it worked.
Then install
gh:Mac
brew install ghWindows
winget install GitHub.cliIf you work in WSL, follow the Linux tab inside WSL instead.
Linux
On Debian, Ubuntu or WSL, follow the apt steps on the cli.github.com install page. They change now and then, so copy them from there.
Open a new terminal after installing.
-
Log in. This one you do yourself, because it opens a browser and asks for your GitHub password.
gh auth loginIt asks a few questions. Pick GitHub.com, then log in with a web browser. It shows a short code, opens the browser, and you paste the code there.
You should see: a line saying you are logged in as your username.
Push your project
Start the agent in your project folder and tell it. Swap meal-picker for your project's name:
Make this a git project if it isn't one and save a snapshot of everything. Then create a public GitHub repo called meal-picker with gh, push to it, and give me the link.
You should see: it runs a handful of commands, asking first, and ends with a link like https://github.com/yourname/meal-picker.
By hand, if you want to see what it ran
Open a terminal in your project folder. Then run these one at a time.
-
Make it a git project, with the main branch called
main. If it already is one, this is harmless.git init -b main -
Pick up every file.
git add . -
Save the snapshot.
git commit -m "first"You should see: a summary of files added. If it says "nothing to commit", you already committed everything. That's fine, go on.
-
Make the repo on GitHub and push to it. Swap
<name>for your project's name.gh repo create <name> --public --source=. --pushYou should see: a link to
https://github.com/yourname/meal-pickerand lines about pushing.
Push again later
Next time you change something, it's one sentence:
Commit and push this.
It writes a sensible commit message and runs the commands. Read what it ran so you learn the moves.
By hand, it's one line
The && means "then, if that worked".
git add -A && git commit -m "add dessert list" && git push
If it didn't
Public or private
Public means anyone on the internet can see the code. Private means only you and people you invite. Both are free.
Public is good for things you want to show off or share. Private is good for anything half-baked or personal. Either way, never put passwords or keys in a repo (see chapter 4). To make one private, use --private instead of --public when you create it.
A note on licences
A licence says what other people may do with your code. Without one, people can look but not legally reuse it. The MIT licence, in one line: anyone can use, copy and change your code, as long as they keep your name on it, and you are not on the hook if it breaks.
Add an MIT LICENSE file with my name and this year. Then commit and push.
What you just did
You made a GitHub account and set your git name and a private email. You had the agent install gh, and you logged in. You pushed your project, and you know how to push again with one sentence, or one line if you prefer.
Next: put it on the internet, at a real address, for free.