Two ways to get a local project onto GitHub: fully via gh, or with plain git + the web UI.
paru -S github-cligh auth loginChoose:
- GitHub.com
- HTTPS/SSH (use SSH if you're a sigma)
- Authenticate via browser
Just follow the steps.
Create a repository from the terminal via gh or plain git.
cd project-dir/
gh repo createFollow the prompts and you'll have a remote repository on GitHub.
cd project-dir/
git initgit init initializes version control in the current folder — it doesn't create a named repo
on GitHub. You'll make the remote on the website next.
- Go to GitHub and create an empty repo.
- Copy either the
https://….git(HTTP) orgit@….git(SSH) URL from theCodebutton. - Back in the terminal, inside the repo, run:
# Add the remote. Use `add` the FIRST time — `set-url` only works if the remote already exists.
git remote add origin git@github.com:<username>/<repo-name>.git
# Push your branch and set it as the upstream (only needed on the first push).
git push -u origin <branch-name>
# Verify the remote is set
git remote -vAfter that first git push -u, later pushes are just git push, and git pull brings down
changes from the remote.
git remote add origin https://github.com/<username>/<repo-name>.git
git push -u origin <branch-name>
git remote -v