Git-The version controller

Git-The version controller

What is it and what it contains and how it works?

ยท

3 min read

Git is a version control system, that makes our life moreover a Software engineer's life better by more organising it.

How to install git?

Just go to this website git(git-scm.com/downloads) and choose your version accordingly like if you are a windows user. If you are a Mac or Linux user you don't have to worry about the downloads because Mac and Linux already contain git. After installation just check with the below command

There are some major components in this git such as:

Repository: This is a folder kind of thing if you want to make it relatable to day-to-day life, But yes this is an important thing for git to track. This contains a major file called .gitignore . Some of us might think that what is the magic by which git can do this wonder? So the answer is by using .gitignore this is a pointer kind of thing that always points out if there is any kind of changes in the file. To make this repository you just have to create a folder and then after then open the folder with gitbash and type the below command like this:

before

After the git init command

Git add command:

By this command, we are allowing git to fetch my changes if there are any. To remember you can imagine you are attaching a CCTV camera to a room ๐Ÿ˜‚. Let's apply this command To specify a file to add in this staging area use this bellow command

To add all the files in this staging area

Git commit command:

By this command, we can record the changes made to the files in a local repository. each commit has a unique ID by this unique id we can fetch this thing. It is always preferred that you should always give a commit message. You can also apply this command like the one below.

Git status command:

This command returns the current state of the repository.

git status shows the current working branch. If a file is in the staging area, but not committed, it shows with git status. Or, if there are no changes itโ€™ll return nothing to commit you can also apply like this

If there are no changes

If there are any changes

git config command:

With Git, there are many configurations and settings possible. git config is how to assign these settings. Two important settings are user user.name and user.email. These values set what email address and name commits will be from on a local computer. With git config, a --global flag is used to write the settings to all repositories on a computer. Without a --global flag settings will only apply to the current repository that you are currently in.

Global Command -

Local Command:

git branch command:

To determine what branch the local repository is on, add a new branch, or delete a branch. You can apply like this.

the way you can play with this command

git clone command:

To create a local working copy of an existing remote repository or if you want to collaborate with someone, use git clone to copy and download the repository to a computer. you can play like this

git push command:

Sends local commits to the remote repository. git push requires two parameters: the remote repository and the branch that the push is for.

Did you find this article valuable?

Support Bipul Mukherjee by becoming a sponsor. Any amount is appreciated!

ย