Your commits so far live only on your computer. Push them to GitHub and they become a backup you can also share with others. Reach this point and you’ve covered the essentials of Git.
1. Create a GitHub account
Sign up from the GitHub home page. All you need is an email address, a password, and a username.
Your username appears in your URLs (github.com/username), so pick one you’d be happy to put on a business card.
2. Create a repository on GitHub
Click + at the top right, choose “New repository,” and decide the following:
| Field | What to enter |
|---|---|
| Repository name | The name of the storage spot. Matching your local folder (my-site) is clearest |
| Description | One line about what it is (optional) |
| Public / Private | Visible to everyone, or only you. Public is fine for learning projects |
| Add a README file | Leave unchecked when you’re pushing an existing local folder |
Once created, you’ll see a page with the commands to run next, including the URL you’ll use below.
3. Register the destination: git remote add
Tell your local folder where to send things. In the terminal, from your project folder:
git remote add origin https://github.com/username/my-site.gitorigin is the nickname for the destination — roughly “the usual place,” and a convention across the Git world. Copy the URL from the page you just saw.
Confirm it registered:
git remote -vSeeing your URL printed back means it worked.
4. Send it: git push
Time to push. Add -u the first time only.
git push -u origin mainorigin— the nickname of the destinationmain— the branch being sent-u— remember “this branch goes here”
When it finishes, reload your GitHub page. Your files listed there means it worked.
From the second time on, the remembered setting makes it short:
git pushWhen authentication gets in the way
You’re asked for a username and password, you type the correct password, and it’s rejected — almost everyone hits this. For security, GitHub dropped password authentication for command-line access.
There are two fixes.
Option 1: Sign in through VS Code (recommended)
Sign in to GitHub from VS Code’s Source Control view and VS Code handles authentication for you. A browser opens, you click approve, and that’s it — by far the easiest route.
Option 2: Create a personal access token
Under GitHub’s Settings → Developer settings → Personal access tokens, generate a string that stands in for your password. When push asks for a password, paste that string.
Your everyday loop
After your project is on GitHub, day-to-day work looks like this:
git add .
git commit -m "Rewrite the profile text"
git pushRecord it, send it. That’s all.
Summary of this lesson
- When creating the repository on GitHub, don’t add a README (it makes the histories disagree)
- Register the destination with
git remote add origin URL, then push the first time withgit push -u origin main - Password rejection is by design. Sign in via VS Code or issue a personal access token