Introduction
I have always used the term Git, Github and Git bash interchangeably, thinking they refer to the same thing, but I have come to learn and understand that GitHub is an online platform on the internet where developers store and share their projects, or repositories. A repository, normally called a repo, is a project being tracked by Git. Git is a version control system that runs on the local computer and can be used to track checkpoints created in a project. Therefore, Git is the tool used to track changes in a project, while SSH, which stands for Secure Shell, provides a secure way to connect your git running on your computer to GitHub on the internet. _ Git Bash _ is a tool or an application that can be used to run Git commands
This guide explains how to upload a project from a local folder on your computer to GitHub.
1. Create a GitHub Account
Go to (https://github.com/) and sign up for an account if you do not already have one.
You will normally provide your email address, password and username for the github account. After creating the account, verify your email address.
After signing in, create a new repository. A repository is a storage space for your project.
When creating the repository, provide a name for the repo, then click Create repository.
2. Install Git on your windows PC
First, install Git on your computer from the official Git website:
[Download Git] (https://git-scm.com/downloads)
After downloading the installer:
- Open your Downloads folder.
- Find the downloaded Git installer.
- Double-click it.
- Allow Windows to run the installer.
- Go through the installation screens.
- For a normal beginner installation, you can generally keep the recommended/default options.
- Complete the installation.
One important tool installed with Git for Windows is Git Bash. After installing it, open git bash and run on the command prompt to check that Git works:
git --version
If Git is installed correctly, you will see its version number.
git version 2.55.0.windows.4
3. Configure Git Username and Email Address
Next, you need to tell git your username and email address associated with your GitHub account. You type on the command prompt
git config --global user.name "Your Full Name" to configure your name and
git config --global user.email "Your Email address" to configure your email
Example:
git config --global user.name "Mohammed Swaleh"
git config --global user.email mswaleh@gmail.com
4. Configure main as the Default Branch
Next, you need to Set main as the Default Branch
Run:
git config --global init.defaultBranch main
This tells Git to use main, as the default initial branch for new repositories.
5. Verify Your Git Configuration
To check your name:
Type in Git Bash
git config --global user.name
To check your email:
type
git config --global user.email
To check all global configuration:
git config --global --list
You should see something similar to:
user.name=Mohammed Swaleh
user.email=mswaleh@gmail.com
init.defaultbranch=main
6. Set Up Secure Shell (SSH)
SSH allows Git to connect securely to your GitHub account without asking for your password every time.
Confirm SSH key exists
Open your terminal and check whether SSH key exists
Type
ls -al ~/.ssh
You can see
id_ed25519
id_ed25519.pub
or older files such as:
id_rsa
id_rsa.pub
if you encounter this error message:
No such file or directory
This means that the SSH key does not exist and you need to create an SSH key
Create an SSH key
Type in the terminal:
ssh-keygen -t ed25519 -C "your_email@example.com"
Replace:
your_email@example.com, with the email associated with your GitHub account.Example:
ssh-keygen -t ed25519 -C "mswaleh@gmail.com"
Press Enter to accept the suggested file location. You can also create a passphrase for extra security.
Confirm That the Key Was Created
type:
ls -al ~/.sshYou should now see:
id_ed25519
id_ed25519.pub
7. ADD THE private SSH KEY TO THE SSH AGENT
The SSH agent helps manage your private SSH key and can remember its passphrase during your session.
To Start the SSH Agent for windows,
open:
PowerShell, as Administrator.On the powershell terminal,
Run:
Get-Service -Name ssh-agent | Set-Service -StartupType ManualThen:
Start-Service ssh-agent
Exit powershell as an administrator, open powershell as a normal user,
Type:
ssh-add c:/Users/YOUR_USERNAME/.ssh/id_ed25519Replace:
YOUR_USERNAME with your actual Windows username.Example:
ssh-add c:/Users/mswaleh/.ssh/id_ed25519If you do not know your Windows username, you can run:
whoami
You may receive something like:
DESKTOP-12345\mswaleh
Your username is therefore, in this example:
mswaleh
8. Windows — Copy the Public SSH Key
Open Git Bash.
Run
cat ~/.ssh/id_ed25519.pub | clip
The public key should now be in your clipboard.If that does not work, display it:
cat ~/.ssh/id_ed25519.pubYou will see one long line similar to:
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAA... mswaleh@gmail.com
Copy the entire line.
9. ADD THE SSH KEY TO GITHUB
On GitHub:
- Click your profile picture.
- Select Settings.
- Open SSH and GPG keys.
- Click New SSH key.
- Give the key a name.
- Paste your public key.
- Click Add SSH key.
GitHub may ask you to confirm your email account.
Complete the confirmation.
Your SSH public key should then appear in your GitHub account.
10. TEST THE SSH CONNECTION
Test GitHub SSH Authentication
Return to:
Git Bash on Windows,
Run:
ssh -T git@github.com
If everything is correctly configured, you should get a message similar to:Hi YOUR_USERNAME! You've successfully authenticated, but GitHub does not provide shell access. This is a success message.
It means:
Computer
↓
Private SSH Key
↓
GitHub verifies the public key
↓
Authentication Successful
11. Open Your Local Project
Use the terminal to move into your project folder.
For example:
cd path/to/your-project
You can check the files in the folder with:
ls
12. Turn the Folder Into a Git Repository
Inside the project folder, run:
git init
This creates a hidden .git folder. Git uses this folder to track changes in your project.
Now check the status of your files:
git status
13. Add a README File
A README file explains what your project is about. Create a file called README.md and write a short description.
Example:
# My First GitHub Project
This is my first project uploaded to GitHub using Git and SSH.
14. Save Your Files in Git
Add all project files:
git add .
The period means "add all files in this folder".
Create your first commit:
git commit -m "Initial commit"
A commit is a saved version of your project. The message explains what was changed.
15. Connect the Local Folder to GitHub
On your GitHub repository page, copy the SSH address. It will look similar to this:
git@github.com:your-username/your-repository.git
Connect your local project to the GitHub repository:
git remote add origin git@github.com:your-username/your-repository.git
You can check the connection with:
git remote -v
16. Upload the Project
Rename your main branch to main:
git branch -M main
Then upload the project to GitHub:
git push -u origin main
The push command sends your committed files from your computer to GitHub.
Refresh your GitHub repository page. Your project files should now be visible online.
17. Updating the Project Later
Whenever you make changes, use these three commands:
git add .
git commit -m "Describe your changes"
git push
For example:
git add .
git commit -m "Add homepage design"
git push
This saves the new changes locally and uploads them to GitHub.
18. Common Problems
GitHub rejects the push
Make sure the repository address is correct:
git remote -v
You can replace the incorrect address with:
git remote set-url origin git@github.com:your-username/your-repository.git
SSH permission denied
Check that your SSH key has been added to GitHub and test the connection again:
ssh -T git@github.com
Files are not uploaded
Check the repository status:
git status
Then add, commit, and push the files:
git add .
git commit -m "Add project files"
git push
Final Git Workflow
The basic workflow is:
git init
git add .
git commit -m "Initial commit"
git remote add origin git@github.com:your-username/your-repository.git
git branch -M main
git push -u origin main
After the first upload, you usually only need:
git add .
git commit -m "Describe your changes"
git push
Conclusion
Moving a project from a local folder to GitHub may seem difficult at first, but the process becomes simple with practice. Git tracks your work, GitHub stores it online, and SSH provides a secure connection between your computer and your GitHub account.
Top comments (0)