git, github-cli
Version control.
Add local project to GitHub
I will utilize the github-cli
for this. One must authenticate before being able to use it, but it will pretty much walk you through it automatically if you try to create a new repository without being authenticated.
Say one have a local project foo
and wants to add this to GitHub.
Navigate to the root of foo
, and do git init -b main
. This will initialize the folder as a git repository and set the initial branch to main
.
Then do gh repo create projectname
and github-cli
will take you through the rest.
When that is done, add and commit as usual.
Branching
Say you are on main
and wants to create a dev
branch.
Creating a branch is done by:
git branch dev
Switching to dev
is then done by:
git checkout dev
Or do it all at once:
git checkout -b dev
Generate and add new SSH key
To generate a new SSH key pair, insert your email and execute the following.
ssh-keygen -t ed25519 -C "[email protected]"
When prompted for a location to store the keys, press Enter to save at the default location, ~/.ssh/
. Enter a password when prompted as well.
One should now have a id_ed25519
and a id_ed25519.pub
within ~/.ssh
. Paste the content of the public key, id_ed25519.pub
, into GitHub under Settings -> SSH and GPG keys -> New SSH key -> Key field.
Reference
Full documentation for github-cli
can be found at https://cli.github.com/ or with gh --help
.
Last updated