Git with Command Line Interface

Faraz Sheikh
4 min readSep 1, 2020

--

Hello guys welcome you once again, so today in these blog you’ll understand Git and Github with CLI commands.

So first you need to understand that Git is distributed version control system and Github is a remote server which is used to store your repositories or repo.

Why Git is popular ?

Previously we using centralized version control system which is not reliable and its only depends on internet so to overcome such issue Distributed version control system is developed.

Story Line :

Git uses Distributed version control structure and Git is developed by Linus Torvald in 2005, He was also the Father of Linux.

Installation :

$ sudo apt-get install git // For Linux/Debian

For windows just tap on these link GIT and install like normal software

Okay now we doing all stuff using command line after installation

Note : Windows user open git bash instead of normal terminal

git --version // For checking git version

Configuration :

Configure means register yourself on git and only on Git not Github

Note :- Git and Github is different as i already said you.

git config --global user.name "Your_Name"
git config --global user.email "Email-id"

After executing above cmd you don’t need to configure again and again it is one time process

For checking your credentials

$ git config --list //Enter// After pressing enter button you'll get below like listdiff.astextplain.textconv=astextplain
filter.lfs.clean=git-lfs clean -- %f
filter.lfs.smudge=git-lfs smudge -- %f
filter.lfs.process=git-lfs filter-process
filter.lfs.required=true
http.sslbackend=openssl
http.sslcainfo=C:/Program Files/Git/mingw64/ssl/certs/ca-bundle.crt
core.autocrlf=true
core.fscache=true
core.symlinks=true
credential.helper=manager
user.name=YOUR_NAME
user.email=YOUR_EMAIL_ID

Now you successfully register your self on Git

Make one folder and by using make directory command like

mkdir Repo1

go inside Repo1 by using change directory command like

cd Repo1/

Finally we are good to go.

Now understand the concept of git repositories, We are using git because it does not require internet because it makes internal partitions which is not appear but it exists

  • Step 1:

For activating git inside your repo just enter below command

git init

Optional :

After pressing git init automatically a hidden folder is created named as .git and it contains several files like configure, index, etc if you want to check those files use below command

$ ls -a ./.git

after entering these command you’ll get all hidden files

./   COMMIT_EDITMSG  description  hooks/  info/  objects/   refs/../  config          HEAD         index   logs/  ORIG_HEAD

Its optional process ignore if you don’t curious about what inside .git folder

Before Step 2 you need to understand about structure/stages of git which you recently activated in your local folder or repo by using git init command

Self Explanatory Image
  • Step 2:

By considering above image we understand there are 3 stages in your local repository that is 1) Working Directory 2) Staging Area 3) Local Repository All these stages is separated in your local repo but it is not appear it is only concept that every geek follows to understand Git easliy

git add .

git add is use for adding your files or data into staging area and forget to use dot in git add command

For frequently checking you are presently on which phase or area use

git status

By using git status you can see all untracked files and phase of git repository structure

git commit -m "Your Message" // msg like commit name or number

No you committed your work and it is ready to push on remote server like Github, Gitlab, etc.

You can check your commit using

git show 

Now after checking and satisfying with your work its time to push your work but before that you need to add your Github repo link or Gitlab repo link

git remote add origin your_url.com

finally push your work on Remote Server by using

git push origin master

Here master means your Github repo branch name, Now the desired files is successfully uploaded on your remote server repository

Step 3:

Similarly for pulling your work from remote server use

git pull -u origin master

After authenticating yourself you’ll get your repo files

If you want desired repository but you don’t have credentials then you can use

git clone <repo_name>

Some Useful commands of Git Bash Terminal

Ctrl+l = is used for clear all command from git bash terminal

which git = is used for finding your path of git

cd .. = is used for going one step back from your current directory

*** Cheat Sheet of Github ***

I hope now you’ll learn about git for advanced version of these blog represent some appreciation as a kudos.

Follow me below handle :

Twitter

Instagram

--

--

Faraz Sheikh
Faraz Sheikh

Written by Faraz Sheikh

Mobile | Web | AI | Opensource | Leadership | Pen | More on : https://farazsheikh.web.app/

No responses yet