Introduction
If you want to upload a project from your computer to your GitHub account, it can be done by simply using Git and SSH. This is one of the most important technical skills you can learn as a beginner because you will use this every time you want to create and or update an existing project. For a person using Windows OS, follow these simple steps as illustrated below.
1. Download Git and create a GitHub account.
The GitHub account can be generated easily on the browser by using your email/username and a password. Git can be downloaded from Microsoft Store and installed in your computer.
2. Set up your Identity.
Since it's your first time you are required to configure your name and email after installation.
Run the following commands on Gitbash
git config --global user.name "Your Name" Insert your name
Then run
git config --global user.email "your-email@example.com"Insert your email, the one used to create your GitHub account
3. Check whether you already have an SSH key
Run:
ls -al ~/.ssh
You'll see
id_ed25519
id_ed25519.pub
id_ed25519refers to the private key and id_ed25519.pub refers to the public key.
4. Generate a new SSH key
Run:
ssh-keygen -t ed25519 -C "your-email@example.com"Replace your email with your GitHub email
You'll then see Generating public/private ed25519 key pair.
Press Enter since it's your first key.
Next you'll see
Enter passphrase (empty for no passphrase):Enter passphrase (password) for security
You'll be asked to confirm your passphrase just enter it again.
You'll see messages indicating the private and public keys are being generated.
On Windows open PowerShell as an Administrator and run:
Get-Service -Name ssh-agent | Set-Service -StartupType Manual
Then:
Start-Service ssh-agent
Return to Gitbash and add your private SSH key:
ssh-add ~/.ssh/id_ed25519
It should indicate that the Identity was added.
5. Add your public SSH key to Github
Run:
cat ~/.ssh/id_ed25519.puband press Enter. Copy the entire line that pops up upto the .pub
On GitHub open Settings → SSH and GPG keys then select New SSH Key give it a title and paste the public key then press add key.
6. Locate your project folder and adding it to GitHub
Locate your project it may be in the documents folder on your desktop. Open Gitbash and navigate into the project folder
cd ~/Documents/Loan Report
You can use ls confirm
Run:
git init -b main initializing an untracked local project.
Then run:
git status this shows the untracked files.
Then run:
git add . this adds the file in the current directory. Rerun git status again.
Then run:
git commit -m "Initial commit"
7. Create a new Repository on GitHub
Create a new repository with a new name preferably the same name as the file Loan Report and choose whether it is public or private.
After creating the repository, you will see the setup information and select and copy the SSH URL. Paste the link in Gitbash then press enter.
Whatever comes up replace the name section with your GitHub username and press enter.
Run:
git remote -v this confirms that Git knows where the GitHub repository is
Then run:
git push -u origin main This pushes a new repository to GitHub.
Afterwards go to GitHub and confirm if the project is there.
Conclusion
This is the basic Git and GitHub steps that you'll have to use repeatedly while working on different kind of projects and with time all of these will become easier.
Top comments (0)