Published on: 26 Oct, 2021

Updated on: 29 Oct, 2021

Setting up git and GitHub account on your system

Lets explore how can we set up git and GitHub account on your system

Here, we will be exploring how to set up Git & GitHub on our system. But the most essential thing is before getting started with GitHub, we have to make sure we have Git installed on our system and also the PATH is set under environmental variable.

1. Setting up git

As per Wikipedia definition, Git is a distributed version-control system for tracking changes in source code during software development. It is designed for coordinating work among programmers, but it can be used to track changes in any set of files.

👉 NOTE: In case you want to learn more about Git, please refer - https://git-scm.com/book/en/v2

So let's get started and dive into the setting up of git on our system and then will jump to GitHub

Firstly, we have to check whether we have git installed on your machine or not using:

git --version

Once we execute this and if we have already git installed and PATH is set, then we will get below output

git version 2.23.0

And, in case we received - git has not recognized or git not found or something else then we need to install git and set the environmental variable PATH

So, let's consider we don't have Git installed on our systems and we have to do the set up from scratch.

Follow the below steps to set up git on your system:

  • Go to https://git-scm.com/
  • Download respective executable/binary file based on system. By default, you will get executable/binary file based on your system. Just click on - Download <version no.> for <system>
  • Run the downloaded executable file and follow the instructions.
  • I know you guys can do it on your own 😎

  • Once the installation is done successfully, let's set up Git environmental variable path

2. Setting up git environmental variable

After successful installation of Git, we must set the path of git bin and cmd folder as a part of environmental variable to avoid the unexpected error or we can say to work with git or github through cmd/terminal

So, let's see how to set up enviromental variable path for git.

For window users

  • Go to "My Computers/Computers"
  • Right-click & select "Properties"
  • In the left panel, click on "Advanced System Properties"
  • Click on "Environmental Variables"
  • Under the System Variables section, select "Path" and click "Edit"
  • Click on "Add" button and add the path of git folders git.exe & cmd file as follows
  • C:\Program Files\Git\bin\git.exe;

    C:\Program Files\Git\cmd;

👉 NOTE: In case you need more details, please visit - https://stackoverflow.com/questions/26620312/installing-git-in-path-with-github-client-for-windows

For Mac & Linux users

In case of Mac & Linux system we don't need to explicitly set the PATH for Git since its already get added at the time of installation.

3. Signing up with github

As we already have done with the git setup, we are ready to track our history and version control. But what if I have to share my code across the team, across different platforms, across the world, and on the internet. So, to do so we need more setup tools to set up and that is - GitHub.

In simple terms, GitHub is a collaboration tool that helps to bring the team closer. It helps the team to share code across and also provides a graphical user interface for the tracked history and commits. These are just a few of them but yes there are a lot more features GitHub provides such as branch creation, pull request creation and merging, repository creation, file creation, cloning, forking, and many more.

So, let get started with GitHub set up on your machine using the following steps:

  • Go to https://github.com/
  • Fill all the necessary details on signup form needed for registration
  • Click on Sign up for GitHub
  • Once we clicked on the signup button, we get a verification mail to our registered email id. Just open your mail and verify your email id by clicking the link send by github
  • I know you guys can do it on your own 😎

  • After clicking on verification link, you will get directed to GitHub site where you have to answers few question and then you are good to go.

4. Creating our first git repository

It's time to create our first repository on GitHub

  • Once you logged in to the GitHub, you will find a green button with name New
  • create repo button
  • After clicking on New button, we will get navigated to GitHub repository creation page.
  • Enter the name of the repository and keep other options default.
  • Click on Create Repository button
  • YEEEE !!! 🤗, we have created our very first github repository

5. Cloning our first git repository to our local system(computer)

It's time to clone our first repository that we have just created on GitHub

  • Once you logged in to the GitHub, you will find your repository <repo-name>
  • new button
  • After clicking on <repo-name>, we will get navigated to GitHub repository content page.
  • Click on Clone & Download button
  • Copy the link of your github repository
  • Open your CMD/Terminal on your local system and navigate to folder where you want to clone your github repository
  • Paste the above copies command with git clone as perfix
  • In my case - git clone https://github.com/letscodedjango/lets-cucumber.git

  • YEEEE !!! 🤗, we have cloned our very first github repository on our local system

6. Adding our first code/file to our local git repository to our local system(computer)

It's time to add our first code/file to local git repository that we have just cloned

There are multiple ways of adding files to local git repository such as through System explorer or using CMD/Terminal

Using System Explorer

  • Navigate to local git folder and add file manually

Using CMD/Terminal

  • Open CMD/Terminal and navigate to local git folder using below command
  • cd <path_to_git_repository>
  • Add new file using - touch filename.py

Once the new file gets added to the local git repository, let's push the same to our remote git repository on GitHub using the following steps:

  • Firstly check the status of out local git repository using - git status
  • It will show all the latest changes we have made to our local git repository

  • If we have any recent changes, we will add the changes to stage area using - git add . or git add filename.py
  • Above command will add all the newly added and modified file to staging area of Git. Here, dot(.) means add all the file & to add specific file use the name of the file

  • After adding file to stage area, we need to commit the changes using - git commit -m "Any message you can give here"
  • Here, 'm' is represeting the commit message. Always give meaning message that is relevant to changes

  • Finally, push the newly added & modified file to GitHub remote repository using - git push
  • Now, you are good to find the recent changes done in local git repo on your GitHub

Share with your love's one!