DEV Community

Cover image for Git and GitHub
Ashray Parmar
Ashray Parmar

Posted on

Git and GitHub

What is Git?

Git is a distributed version-control system for tracking changes in source code during software development. It creates a local repository in our computer in which we will make local changes.

What is GitHub?

It is a place where your Local Repository can be uploaded to Remote Repository on GitHub.

Requirements?

We need to create an account on GitHub, now it is time that we push our local data to a remote location at GitHub.

Git Commands

Let's begin with the most used git commands.

Where will you type the commands? Open terminal with the project path;

  • git init

This will initialize a local repository in your project folder.

  • git add .

This command will add the project files in the staging area which will be ready to commit or push in GitHub.

  • git status

This will check whether your files are in Staged area or not?

What is staged area?

The staging area is a container where git collects all changes which will be part of the next commit it collects all the changes to be committed collectively before they will be pushed to GitHub.

  • git commit

Commit set a message about the changes you were done. The commit also saves a revision of the code and you can revert the code to any version anytime in one click. We can always add commit message by this command git commit -m "fix" this message is used if any bug is fixed in the code.

  • git push/pull

git push command is used to transfer or push the commit, which is made on a local branch in your computer to a remote repository like GitHub.

git pull is a Git command used to update the local version of a repository from a remote, suppose if any other developer made changes in the remote repository by this command you can update it to your local repository.

Top comments (0)