The store’s repository on GitHub is still empty, and your laptop knows where it lives. In the last lesson, the check report even named the command that fills it, git push -u origin main. So far, GitHub has never heard of your laptop, though, and it isn’t going to accept the store’s whole history from a computer it doesn’t know. With the starter project, that history is 22 commits.
In this lesson, you’ll push the site’s whole history to GitHub and connect your main branch to the one there. On the way, you’ll find out what GitHub accepts as proof that the push is yours, and you’ll create a token that can push to this one repository and nothing else. Start with the command the check report suggested and see what GitHub asks for.
Push and Meet GitHub’s Sign-In
A push sends the commits that your branch has and the remote’s branch doesn’t, and then moves the remote’s branch to match. It moves an existing branch only when the new commits build on everything that branch already has, so a plain push never throws away commits that only the remote has.
GitHub’s main doesn’t exist yet, so this first push sends everything. In the terminal in your generic-grocery folder, run the command from the report:
$ git push -u origin main
Reading your public repository works without signing in, but changing it doesn’t, so GitHub asks who you are before it takes anything. What you see next depends on your system:
Most people go for the highlighted button, because it looks like the way to sign in. It would work, but it gives Git Credential Manager access to every repository on your GitHub account, with permission to change all of them. That’s far more than pushing one site needs.
Note: On macOS and Linux, VS Code’s integrated terminal can pass Git’s question to VS Code. If VS Code offers to sign you in to GitHub in the browser, then cancel the sign-in, because it asks for the same account-wide access as Windows’ browser sign-in. VS Code then shows Git’s Username for 'https://github.com': prompt in a box at the top of its window, followed by the password prompt, and the rest works the same way.
On macOS and Linux, Git refused the push. Take a closer look at the line that starts with remote:, because that’s GitHub talking. It doesn’t say the password was wrong. It says that password authentication isn’t supported for Git operations at all.
GitHub stopped accepting account passwords for Git in August 2021. Your password still signs you in on the website, but when Git pushes, GitHub wants something that can be limited and taken back without touching your account. Git’s only role is to pass your answers along, which is why the prompt still says Password.