Git Basic Commands for Beginner

Git basic commands for beginners

Hey, you landed good tutorial for git basic commands, here you can learn different types of git basic commands.

Before you start commands you must know what is git.

What is git?

Git is a software that is used for Version Control. It is free and open source.

Version Control

Version control is stores the project files into different types of versions. You can take backup or roll back your commits to previous step.

Git allows a team of people to work together and it helps the team, multiple people work same file avoid confusion of which one working on which code snippets.

For more information click here

git initialization

After installation of git you must git initialization in your project folder by using below command.


git init

Config git email for Your Identity

The first thing you should do when you install Git is to set your user name and email address. This is important because every Git commit uses this information.

For set gobally by using below commands.

Set Email Gobally by using below command


$ git config --global user.email "example@mail.com"

Set Username Gobally by using below command


$ git config --global user.name "Venugopal"

It will set to all projects in your system.

Set Git Email or Username to Repositories basis

git allows you to specify email addresses on a per repository basis. This is very useful for when you working with repositories from multiple organisations.

Set Email per Repository by using below command


$ git config user.email  "example@mail.com"

Set Username per Repository by using below command


$ git config user.name "Venugopal"

Other useful commands for Git

Check User Email:
=================
$ git config user.email

Push
===========
$ git add .
$ git commit -m "Changed something"
$ git push

Pull
============
$git pull

Check Commits Logs:
=============
$ git log master
Press 'q' to stop

Adding File:
==================
$ git add.
$ git add index.html
$ git commit -m "Added New file"
$ git push

Remove File:
==================
$ git rm file1.txt
$ git commit -m "remove file1.txt"

Rename File:
==================
$ git mv #oldfile #newfile
$ git commit -m "rename oldfile to newfile"
$ git push
start a project with us