DEV Community

Cover image for My First GitHub Project: From a Local Folder to GitHub Using Git and SSH
Wendy Adika
Wendy Adika

Posted on Edited on

My First GitHub Project: From a Local Folder to GitHub Using Git and SSH

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:
    pwd which stands for print working directory. Working directory is the folder you are currently in.
    You can move to intended directory using the cd command.

  • To initialize the folder as a Git repo(repository) run:
    git init

This will appear:
git innit command

  • Also check for git's hidden files by running: ls -la You 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
git status command

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:
git commit command

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** git remote add origin command
  • To confirm that Git can send and receive information from the correct github repo run: git remote -v git remote -v command .
  • To push your project run: git push -u origin main This 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)

Collapse
 
dataanalyst_bree profile image
Brigid Chepkemoi

Good Work!