Common workshop tasks
Most of our workshops start with the same few setup steps. This page collects them in one place, so you can get them done before the workshop starts and spend the evening on the fun part. If you get stuck, ask one of the organizers - that's what we're there for.
Setting up Git and GitHub access
After following these steps you will have Git installed and configured, a GitHub account, and a working
way to git push and git pull without being asked for a password.
1. Install Git
Open a terminal. On macOS, look for the app called "Terminal". On Windows, use Windows Terminal or "Git Bash". Then check whether Git is already installed:
git version
If it prints a version number, you're good. If the command is unknown, follow GitHub's Install Git guide.
GitHub Docs: Set up Git
2. Create a GitHub account
If you don't already have one, sign up at github.com. It's free and only takes a minute. Make a note of your GitHub username; you'll need it later.
3. Tell Git who you are
Every commit records a name and an email address. Check whether you have already set them:
git config --global user.name
git config --global user.email
If either prints nothing, or the email isn't the one you use on GitHub, set them (replace with your own name and email):
git config --global user.name "Your Name"
git config --global user.email your.name@email.com
Use the same email address as your GitHub account. GitHub uses it to link your commits to your profile; with any other address, your commits won't show up as yours.
Optionally, make Visual Studio Code the editor Git opens when it needs you to write something, such as a merge message:
git config --global core.editor "code --wait"
GitHub Docs: Setting your username in Git, Setting your commit email address, Associating text editors with Git
4. Check if you already have access
If you have pushed to GitHub before, you may already be set up. There's no reason to set up a second method, so check first.
HTTPS: run
git config --global --get-regexp '^credential'
If it prints a line containing any of these, a credential helper is already configured and you can skip to You're done:
| Output contains | What it is |
|---|---|
gh auth git-credential |
GitHub CLI (what step 5 sets up) |
manager |
Git Credential Manager |
osxkeychain |
The macOS keychain helper |
wincred |
The Windows credential store |
libsecret or store |
Common helpers on Linux |
SSH: run
ssh -T git@github.com
A reply like Hi <your-username>! You've successfully authenticated... means SSH works.
(It also says GitHub doesn't provide shell access - that's expected, not an error.) Keep using SSH, and
pick the SSH tab whenever GitHub shows you a repository address, so it starts with
git@github.com:. If you get Permission denied (publickey) instead, continue with
step 5.
GitHub Docs: Caching your GitHub credentials in Git, Testing your SSH connection
5. Log in with the GitHub CLI
You can't use your GitHub password with Git - GitHub removed password authentication in 2021 - so
something has to store a credential for you. In our workshops we use HTTPS together with the
GitHub CLI (gh), because it sets up
both itself and Git in one go, with no keys to manage.
Install it:
winget install --id GitHub.cli # Windows
brew install gh # macOS
On Linux, follow the installation instructions for your distribution. You may need to open a new
terminal window after installing before gh is found.
Then log in:
gh auth login
Answer the prompts like this:
- What account do you want to log into?
GitHub.com - What is your preferred protocol for Git operations?
HTTPS - Authenticate Git with your GitHub credentials?
Yes - How would you like to authenticate?
Login with a web browser, then follow the steps in your browser
The third answer is the important one. It registers
ghas Git's credential helper, sogit pushandgit pullwork without asking you for anything.
Check that it worked:
gh auth status
git config --global --get-regexp '^credential'
gh auth status should say you are logged in, and the second command should print a line
ending in gh auth git-credential. If it prints nothing, you probably answered "No" to the
third prompt. Fix it without logging in again:
gh auth setup-git
Note that gh registers itself only for github.com
(as credential.https://github.com.helper), which is why we list all credential settings
instead of asking for plain credential.helper - that one would look empty even when
everything works.
GitHub Docs: About remote repositories, Caching your GitHub credentials in Git. GitHub CLI manual: gh auth login, gh auth setup-git
Alternatives
- Git Credential Manager - if you'd rather not install the GitHub CLI. It's included
with Git for Windows 2.29 and newer. On macOS, run
brew install --cask git-credential-manager. On Linux, see the installation guide. - SSH keys - just as good, and you'll meet them on real projects, but they take longer to set up. See Connecting to GitHub with SSH.
- GitHub Desktop - for workshops that don't require the command line, GitHub Desktop is a beginner-friendly option that installs Git and handles login for you.
GitHub's own write-up of the HTTPS options is Caching your GitHub credentials in Git.
You're done
The first time you git push over HTTPS you may see a browser window or a prompt. After that,
pushing and pulling should just work. To try it out, clone one of our workshop repositories:
git clone https://github.com/nerdschoolbergen/git.git
Some workshops ask you to fork the repository first (make your own copy on GitHub with the
Fork button), and then clone your fork:
https://github.com/<your-username>/<repository>. The workshop's exercises will
tell you which to do.
GitHub Docs: Cloning a repository, Fork a repository