Git & GitHub・Putting it on GitHub

Putting it on GitHub — from account to push

The full path from creating an account to sending your commits to GitHub — making a repository, registering the remote, and pushing. Includes the authentication problem everyone hits when their password is rejected.

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.

GitHub

2. Create a repository on GitHub

Click + at the top right, choose “New repository,” and decide the following:

FieldWhat to enter
Repository nameThe name of the storage spot. Matching your local folder (my-site) is clearest
DescriptionOne line about what it is (optional)
Public / PrivateVisible to everyone, or only you. Public is fine for learning projects
Add a README fileLeave 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.git

origin 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 -v

Seeing 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 main
  • origin — the nickname of the destination
  • main — 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 push

When 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.

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 push

Record it, send it. That’s all.

Summary of this lesson

  1. When creating the repository on GitHub, don’t add a README (it makes the histories disagree)
  2. Register the destination with git remote add origin URL, then push the first time with git push -u origin main
  3. Password rejection is by design. Sign in via VS Code or issue a personal access token

FAQ

Why does GitHub reject my password when I push?
GitHub no longer accepts your account password for command-line authentication. Either sign in through VS Code, or create a personal access token and use that in place of the password.
Should my repository be public or private?
For learning projects, public is fine. Choose private if you don't want it seen, or if configuration files might contain personal details. You can change it later.
What does the -u in git push -u origin main do?
It records "this branch goes here." Use it once, and after that plain git push sends to the same place.