This tutorial guides on how to push your local projects to Github using Git and SSH.
The prerequisite steps are:
- Installed and configured Git using your user name and email.
- Set up your Github account.
- Generated and added your public ssh key to your Github.
- Tested your ssh connected and make sure it is successful.
- Created a local project with Readme file, data ,scripts and notebooks where applicable.
Step 1: Project Initialization With Git
Open gitbash terminal.
Before initialization, ensure your location(which is at the end of the path) is the project folder you intend to push.
Run:
pwdwhich stands for print working directory. Working directory is the folder you are currently in.
You can move to intended directory using thecdcommand.To initialize the folder as a Git repo(repository) run:
git init
- Also check for git's hidden files by running:
ls -laYou should see .git among files. .git folder acts as the git memory.
Step 2: Check Status
To check the current status of your working directory and staging area run:
git status

Because it is a new project, the files are untracked.
Step 3: Add
To prepare our project files for the next commit you run:
git add .
Step 4: Commit
To save any changes to your project files run:
git commit -m "----"
Inside the quotes, write a message that explains what was saved.
See example:

Always ensure that the branch is main.
Step 5: Pushing to Github
Create a New Github Repo
- Sign in to your github account.
- Create a new repo- should be empty.
- Fill in new repo form then click on create(Repo name, description and choosing either public or private, the rest you can skip).
- Click on ssh then copy ssh address.
Go Back To Gitbash
- Ensure location is still project folder.
- To link your local git repository to your github repository run:
git remote add origin **the_copied_ssh_address**
- To confirm that Git can send and receive information from the correct github repo run:
git remote -v
. - To push your project run:
git push -u origin mainThis means that git has sent any commited changes to your github repository. - Confirm your project has been pushed to github by refreshing the page.

Top comments (1)
Good Work!