How to add a Machine Learning Project to GitHub

Nantha Kumar Senthilkumar
Analytics Vidhya
Published in
3 min readAug 22, 2020
Photo by Richy Great on Unsplash

This tutorial is mainly focussed on data science beginners who are new to GitHub.

Maintaining a GitHub data science portfolio is very essential for data science professionals and students in their career. This will essentially showcase their skills and projects.

What is GitHub?
GitHub is a code sharing and publishing service. At the heart of GitHub is Git, an open-source project started by Linux Creator Linus Torvald. Git, like other version control systems, manages and stores revisions of projects.

If you are curious to know about how Git and GitHub works you can always google them to find more.

Steps to add an existing Machine Learning Project in GitHub

  • Let’s start by installing Git on our system. To do this we will use the git command-line interface which can be downloaded from here. Follow the instructions according to Windows or Mac for the installation process. Note: There are different ways to add a project, we will be using the traditional git-bash command-line interface for this article.
  • If you are already having a GitHub account login to it or create a GitHub account here. Then we can create a repository for our project. It’s always a good practice to initialize the project with a README file.
Type in a new repository name for your project
  • Go to the Git folder located in C:\Program Files\Git and open the git-bash terminal.
  • Now navigate to the Machine Learning project folder using the following command.
cd PATH_TO_ML_PROJECT
  • Type the following git initialization command to initialize the folder as a local git repository.
git init

we will get a message “Initialized empty Git repository in your path” and .git folder will be created which is hidden by default.

  • Now we will add our file to the staging area for committing using this command which adds all the files and folders in your ML project folder.
git add .

Note: git add filename.extension can also be used to add individual files.

  • We will now commit the file from the staging area and add a message to our commit. It is always a good practice to having meaningful commit messages which will help us understand the commits during future visits and revision. Type the following command for your first commit.
git commit -m "Initial project commit"

This only adds our files to the local branch of our system and we have to link with our remote repository in GitHub

  • To link them go to the GitHub repository we have created earlier and copy the remote link under “..or push an existing repository from the command line”
Git Remote URL for pushing an existing repository
  • In the git-bash window, paste the command below followed by your remote repository’s URL.
git remote add origin YOUR_REMOTE_REPOSITORY_URL

Note: Replace the YOUR_REMOTE_REPOSITORY_URL with your remote URL

  • Now finally, we have to push the local repository to the remote repository in GitHub
git push -u origin master

After this, the Machine Learning project will be added to your GitHub with the files.

🙌 We have successfully added an existing Machine Learning Project to GitHub. Now is the time to create your GitHub portfolio by adding more projects to it.

Thank you for reading this article. Hope you have gained some knowledge about working with GitHub.

--

--