Git for beginners 🚀

Purvesh P. shende
3 min readJan 13, 2021
Version control system

Welcome to Git for beginners blog, Hope you are doing well and staying home and staying safe, Here is git cli blog
So ,
what is git -
Git is distributed version control system for tracking changes in source code during Software development . It is designed for coordinating work among programmers ,but it can be used to track changes in any set of file. Its goals include speed, data integrity ,and support for distributed non linear workflows.

How to install Git
Go to the Git Website

Getting started -
What is a git repository -
This is a folder inside your project where git tracks all the changes made in the files and build a history reference over time. In your project the git repository folder you will see a .git folder.
Basic Commands –
To create a folder : mkdir Hello
To create a file: touch index.html style.css
To delete a file : rm index.html
To see inside a folder : ls (Ls)/ dir
To move up a folder : cd ..
To delete a folder : rmdir Hello
To go in any folder : cd <Folder_name>

To get started with Git, go to your terminal and run the following command in your project directory.

Git config -

To set your user name and email in the main configuration file.

Command -

git config –global user.name “robin”git config –global user.email “robin@example.com”

Git init –

To initialise a git repository for a new or existing project.

Get into root directory and type following command.

Command –

git init

Git Clone-

Git clone is a git command line utility which used to target an existing repository and create a clone , or copy of that target repository , also sets the remote to original source so that you can pull again.

Command-

git clone <git url to clone>

Git status-

To check the status of files you’ve changed in your working directory

Command-

git status

Git add -

To add changes to your working directory so that git can index those files.

Command –

To add all changed files to git or

Just type “git add filename”

git add .

Git Commit -

This command is use for to commit changes you have made and sets it to new commit object for your remote

Command –

git commit -m"your message”

Git Pull / Push -

This command is use for push or pull your changes to remote . If you have added and committed your changes and you want to push them and if your remote has updated and you want those latest changes.

Command –

git pull<remote><branch> andgit push<remote><branch>

Git Branch –

It will list out all of the branches

Command –

git branch or git branch -a to list remote branches as well.

Git checkout –

To switch between different branches.

Command –

git checkout <branch name> orgit checkout -b<branch name>

Git Stash –

To save changes that you don’t want to commit immediately.

Command –

git stash or 
git stash apply

Git merge –

To merge two branches you are working

Command –

First checkout the branch into which you want to merge other branch and then type.

git merge <name_other_branch>

Git logs –

This will list all of the commits you have made into working directory this shows the history of commits with their ids and information.

Command –

git logs

Git Revert –

To revert the changes to last commit.

Command –

git revert<commit-id>

Git Remote –

To check what remote/ source you have or you want to add a new remote

Command –

git remote and git remote add <remote_url>

Thank you for reading my blog. Feel free to connect on LinkedIn or Twitter :)

--

--