Exercises — Stage 7: Connect to GitHub
Exercise 1: Inspect .git/config
Goal: See where the remote is actually stored.
Steps:
- Run
cat .git/config. - Look for a
[remote "origin"]section.
What happened: The remote is just a few lines of text in .git/config. Nothing magical. If you wanted to, you could edit that file by hand — but use git remote commands instead so Git validates the input.
Exercise 2: Remove and re-add the remote
Goal: Practice the full lifecycle of a remote.
Steps:
- Run
git remote remove origin. - Run
git remote -v— no remotes listed. - Run
git remote add origin https://github.com/<your-username>/box-runner.gitagain. - Run
git remote -v— origin is back.
What happened: Removing a remote only deletes the local pointer. The GitHub repo is untouched. You can add and remove remotes freely.
Exercise 3: Change the URL
Goal: Learn git remote set-url.
Steps:
- Run
git remote set-url origin https://github.com/<your-username>/box-runner.git(same URL — pretend it changed). - Run
git remote -vto confirm.
What happened: set-url replaces the existing URL instead of adding a new one. Useful when you move a repo between accounts or migrate between hosts.
Exercise 4: Peek at the empty repo on GitHub
Goal: Get familiar with the GitHub UI.
Steps:
- Go to your repo page on github.com.
- Find the "Quick setup" box.
- Read the commands GitHub suggests — you will recognize most of them.
What happened: GitHub offers two flows: "create a new repository on the command line" and "push an existing repository." You are doing the second flow, manually.