Git and GitHub Basics

Pradyumna Das
4 min readJan 31, 2023

--

What is Git?

Git is a distributed version control system (VCS) used for tracking changes in computer files and coordinating work on those files among multiple people. It is primarily used for software development, but it can be used to track changes in any set of files. With Git, you can keep a record of your code history, revert to previous versions, collaborate with others, and easily manage and merge contributions from multiple sources.

Git stores its data in a local repository on the user’s computer, and it can be used in conjunction with remote repositories hosted on services such as GitHub, GitLab, and Bitbucket, to allow for collaborative development.

What is GitHub?

GitHub is a Distributed version control platform where individuals and teams can store and manage their code, as well as collaborate on projects. GitHub is an open-source software development platform, where developers can share and contribute to open-source projects. In addition, GitHub offers paid plans for businesses and organizations that need to host private repositories and access advanced features.

Before going into git and GitHub we have to know about basic terminologies, there is a term called Sourcecode management.

It has two types…

DVCS and CVCS

DVCS (Distributed version control system):

  1. Each user has a full copy of the repository on their local machine.
  2. Changes can be committed and managed locally, without relying on a central server.
  3. Branches can be easily created and merged, promoting collaboration and decentralization.

CVCS(Centralized version control system)::

  1. There is a single central repository that all users must connect to in order to access the code.
  2. Changes are committed to the central repository and managed there.
  3. Branching and merging can be more complicated, as all changes must be coordinated through the central repository.

Create an Account on Github and clone the repository

Go to the github.com Sign Up page and make your account.

After creating a GitHub account let’s do some exercises:

After creating an account the page looks like this

  • Create a new repository on GitHub and clone it to your local machine.

To create a repository click on the right top corner “+” icon and select New repository.

After clicking on New repository, will get this page, give the name of the repository then choose public, if you could choose private also. If you want to show your repository to everyone, then choose public and click on “create repository”.

After clicking create repository a new page will open, that will give some commands to execute in the terminal. Go to your system and execute these commands where you execute your code.

Before executing these command you should add your name and email id. For adding name and email id use the below command.

git config --global user.name "Your_Name"
git config --global user.email "your_email@yourdomain.com"

To clone the repository copy the https URL and use the command git clone and paste the URL.

After cloning the repo, we will create a file and execute all commands.

If you are getting any authentication error when you are pushing code to remote repo use the below steps.

error

remote: Anonymous access to scuzzlebuzzle/ol3-1.git denied.

fatal: Authentication failed for 'https://github.com/scuzzlebuzzle/ol3-1.git/'"
  • In the upper-right corner of any page, click your profile photo, then click Settings.
  • In the left sidebar, click Developer settings.
  • In the left sidebar, under Personal access tokens, click Fine-grained tokens.
  • Click Generate new token.
  • use the below command to authenticate
git clone https://github.com/USERNAME/REPO.git
Username: YOUR_USERNAME
Password: YOUR_TOKEN

After doing all push the file to your remote.

This is all about today's Blog. we will discuss Git and Git hub more in the next blog.

Stay tuned for the next Blog.

Connect with me:

LinkedIn: https://www.linkedin.com/in/pradyumna11/

--

--

Pradyumna Das

Engineer who loves writing on DevOps, Linux, and IT Support