Git, GitHub, and Version Control

What is Git?

Git is an open-source distributed version control system, which we can use to save different types of files and allow us to record changes that we did for files, and also we can view each change we did. Git is helpful to a group of developers to work on a single project.

What is GitHub?

GitHub allows us to host our git project on a remote server somewhere. it is a user-friendly client application for git. it can be used to view and edit code from the website. GitHub now supports various cloud providers like Azure, AWS, GCP to automate the development pipelines.

What is Version Control?

Version control is the practice of tracking and managing changes to software code. Version control systems are software tools that help software teams to manage changes to source code over time. Version control systems help software development teams to work faster and smarter.

Let’s see how we can install and use Git and GitHub

Install git to your computer

Create a new GitHub account

  • Now you have installed Git on your computer. let's sign up and create an account on GitHub.
  • Use this link, https://github.com/

Setup Github on Computer

  • Now you have created an account on GitHub. Let’s set up your computer. Open up a terminal or command prompt and type the below command.
git config --global user.name "GitHub User Name"
git config --global user.email "email"

Let's create a new repository on GitHub

Using this link go to your GitHub account, https://github.com/

  • In your dashboard left side under the repository section, you will notice a green color icon “New”. Click on that icon,
  • Fill out your form like this and click on the “Create Repository” button.
  • Once the repository is created, it looks like this,

Git Commands

  • Git clone

Git clone is a command, which we can use to download the existing source code from the repository. It makes a copy of the latest version of a project in a repository and saves it to your computer. use the below command to clone the project.

git clone <repository-link>

also, you can download the source code from the repository. Go to your repository and on the right side of the page you will notice a green color icon “Code”. Click on that icon and you will get the drop-down list. At the bottom of the drop-down list, you can see the “Download ZIP” option.

  • Git Branch

In git, Branches are highly important. Using branches developers are able to work on the same project simultaneously. we can use the below commands to create, view, and delete branches.

Create branches,

git branch <branch-name>

View branches,

git branch --list

Delete branch,

git branch -d <branch-name>
  • Git checkout

To work in a branch, first, we need to switch to it. In git, we use the “git checkout” command to switch from one branch to another. Use the below command,

git checkout <branch-name>
  • Git status

This command we can use to get all the necessary information about the current branch. Use the below command,

git status
  • Git add

This command we use to include the changes of a file into the next commit. we can use the below command,

git add .
  • Git commit

Once we did a certain point in development, we need to save our changes. Git commit is like a checkout point in the development process which we can go back later to check our changes if needed. and also we need to write a short message to explain what we develop in the source code at that time. Use the below command to commit,

git commit -m <commit massage>
  • Git push

After committing the changes we need to send our changes to the repository. this command uploads commit to the repository. Use the below command,

git push origin < branch name>
  • Git pull

This command is used to get all the updates from the repository. it updates from the repository and applies the latest changes in a local project. Use the below command,

git pull origin <branch name>

Hope you learned something from this article.

Thank you.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store