create github repository for beginners - Dieptranivsr/DroneIVSR GitHub Wiki
- Configure Git in WSL
- Generate a new SSH key
- Add a new SSH key to your GitHub account
- Create and upload a local repository
Configure Git in WSL
Requirements
My two assumptions for this are that you have Windows 10/11 and WSL already installed. The terminal commands used are based off of Ubuntu/Debian based Linux distributions.
Git Config
Git should come pre-installed on most, if not all of the WSL Linux distributions. To ensure you have the latest version, use the following command in an Ubuntu or Debian based distro:
$ sudo apt install git
Name
To set up your Git config file, open a WSL command line and set your name with this command (replacing "Your Name" with your preferred username):
git config --global user.name "Your Name"
Set your email with this command (replacing "[email protected]" with the email you prefer):
git config --global user.email "[email protected]"
Username
And finally, add your GitHub username to link it to git (case sensitive!):
git config --global user.username "GitHub username"
Credentials
$ git config --global credential.helper store
Generate a new SSH key
You can generate a new SSH key on your local machine. After you generate the key, you can add the key to your account on GitHub.com to enable authentication for Git operations over SSH.
Open Git Bash
Paste the text below, substituting in your GitHub email address
$ ssh-keygen -t ed25519 -C "[email protected]"
When you're prompted to "Enter a file in which to save the key", you can press Enter to accept the default file location.
Add a new SSH key to your GitHub account
You can access and write data in repositories on GitHub.com using SSH (Secure Shell Protocol). When you connect via SSH, you authenticate using a private key file on your local machine
- Copy the SSH public key to your clipboard.
$ cat ~/.ssh/id_ed25519.pub
# Then select and copy the contents of the id_ed25519.pub file
# displayed in the terminal to your clipboard
- In the upper-right corner of any page, click your profile photo, then click Settings.
- In the "Access" section of the sidebar, click SSH and GPG keys. And click New SSH key or Add SSH key.
- In the "Title" field, add a descriptive label for the new key. For example, if you're using a personal laptop, you might call this key "Personal laptop".
- Select the type of key, either authentication or signing, eg: authentication
- In the "Key" field, paste your public key. Click Add SSH key.
Create and upload a local repository
$ git init -b main
or $ git init && git symbolic-ref HEAD refs/heads/main
$ git add *
$ git commit -m "any comments"
$ git remote add origin URL eg: https://github.com/Dieptranivsr/commonapi_someip_example.git
$ git remote -v
$ git push origin main
This is an example of what the .gitignore file could look like:
# Ignore Mac system files
.DS_store
# Ignore node_modules folder
node_modules
# Ignore all text files
*.txt
# Ignore files related to API keys
.env
# Ignore SASS config files
.sass-cache