git, bitbucket, git command,git tutorial,beginner git command, essential git command, what is git, version control tool, git setup in local directory
Git is an opensource tool to handle everything in a large project
It increases
performance, security by cryptographic algorithm sha1.
Git is
developed by LINUS TORVLDS who developed Linux operation system
Git is a version control tool: It means we can track the working
history of each developer who is working on a particular project.
Type of
version control tool: centralized and distributed
Centralized version control tool:
all developers do changes in a project centrally. This keeping files in drive
manually ex.svn,cvs
Distributed version control tool: all
developers work on the local directory stage it pushes to central project this idea
come in 2005.
In this, each
developer have a copy of the repository and history of all development
Each
developer have control over their code separately
Ex: git
mercurial, bazaar
How to
git work

Let you have a working directory in which we code then add in the staging area by adding git add <filename> it is not a physical directory (virtual directory)after commit it add into local directory
The most prominent remote repository are Github, bitbucket, Gitlab
Now we
discuss about local system
Download git
Install it
Check git
version: git –version
If show
version git installed successfully
Now we create a local system in our window os
Git has
three levels of configuration
System-level
configuration: This configuration is applicable to the entire system machine. All users
on operating system + all repository
Global-level
configuration: Specific user on an operating system + all repository
Local-level
configuration: Specific user on an operating system + local repository
Order of
priority
System<global<local
Let’s start
with system-level configuration open cli as administration
$ git config --system user.name “virendra s”
$ git config --system user.email veeru@gmail.com
Let's check system-level configuration
$ git config --system --list
To check specific element
$ git config --system user.name
$git config --system user.email
To check all the properties of the system-level configuration
$ git config --system --list
--show –origin
Global level configuration
$ git config --global user.name “virendra
g”
$ git config --global user.email veerug@gmail.com
To check global configuration property
$ git config --global --list
Local-level configuration
Create a local repository go-to repository and create the configuration
user@user-PC MINGW32 /d
$ mkdir -p repository
user@user-PC MINGW32 /d
$ cd repository
user@user-PC MINGW32 /d/repository
$ mkdir localrepository
user@user-PC MINGW32 /d/repository
$ cd localrepository
user@user-PC MINGW32 /d/repository/localrepository
$
To Check
local repository is blank or not
user@user-PC MINGW32 /d/repository/localrepository
$ ll
-a
total
0
drwxr-xr-x
1 user 197121 0 Sep 3 20:01 ./
drwxr-xr-x
1 user 197121 0 Sep 3 20:01 ../
Initialize git
user@user-PC MINGW32 /d/repository/localrepository
$
git init
Initialized
empty Git repository in D:/repository/localrepository/.git/
Check
local repository
user@user-PC MINGW32 /d/repository/localrepository
(master)
$ ll
-a
total
4
drwxr-xr-x
1 user 197121 0 Sep 3 20:11 ./
drwxr-xr-x
1 user 197121 0 Sep 3 20:01 ../
drwxr-xr-x
1 user 197121 0 Sep 3 20:11 .git/
It has four files one is git and the local repository branch name is master
now set the
local configuration
user@user-PC MINGW32 /d/repository/localrepository
(master)
$
git config --local user.name "virendra l"
user@user-PC MINGW32 /d/repository/localrepository
(master)
$
git config --local user.email "veerug@gmail.com"
user@user-PC MINGW32 /d/repository/localrepository
(master)
$
git config --local --list
core.repositoryformatversion=0
core.filemode=false
core.bare=false
core.logallrefupdates=true
core.symlinks=false
core.ignorecase=true
core.hidedotfiles=dotGitOnly
user.name=virendra
l
now
see my name and email set locally
CLI(Command Line) editor
Vim
is the default editor of git
but git allow to change git by setting core.editor
$
git config --global core.editor emac(mac)
In
mac, emac is the default editor by running the above command
$git
config --global core.editor
“nano”(linux)
Nano
is the default editor by running the above command
$
git config --global core.editor
“’C:/ProgramFiles/Notepad++/notepad++.exe’-multilnst –notabbar –nosession
-noPlugin”
In notepad++ can be default editor by above command
Let's add some files in the local directory using the command
user@user-PC MINGW32 /d/repository/localrepository
(master)
$
cat > sampletextfile1.txt //enter
this
is a sample text file //add some text
text is
ok //add some text
press
ctrl c to back in the directory
List the file
user@user-PC MINGW32 /d/repository/localrepository (master)
$ ls
sampletextfile1.txt
Let's
copy the file
user@user-PC MINGW32 /d/repository/localrepository (master)
$
cat > file1.txt
this
text file 1
user@user-PC MINGW32 /d/repository/localrepository
(master)
$ cp
file1.txt file2.txt //text copy from
file1.txt to file2.txt and create the file
user@user-PC MINGW32 /d/repository/localrepository
(master)
$ cp
file1.txt file3.txt
user@user-PC MINGW32 /d/repository/localrepository (master)
List of files
user@user-PC MINGW32 /d/repository/localrepository (master)
$ ls
file1.txt file2.txt
file3.txt sampletextfile1.txt
now
there is four files in the working directory
Now
add 1 file in the staging area
user@user-PC MINGW32 /d/repository/localrepository
(master)
$
git add file1.txt
Check
git status the file which is add in staging area showing in green color and
other file showing in red color
user@user-PC MINGW32 /d/repository/localrepository
(master)
$
git status
On
branch master
Initial commit
Changes to be committed:
(use "git rm --cached
<file>..." to unstage)
new
file: file1.txt
Untracked
files:
(use "git add <file>..." to
include in what will be committed)
file2.txt
file3.txt
sampletextfile1.txt
user@user-PC MINGW32 /d/repository/localrepository
(master)
1.file1.txt
in green color are stage means this file in the staging area
2. Other
three files in red color are unstaged means these are still in the working area
=>Add
two more files in staging area
user@user-PC MINGW32 /d/repository/localrepository
(master)
$
git add file2.txt file3.txt
user@user-PC MINGW32 /d/repository/localrepository
(master)
$
git status
On
branch master
Initial
commit
Changes
to be committed:
(use "git rm --cached
<file>..." to unstage)
new
file: file1.txt
new
file: file2.txt
new
file: file3.txt
Untracked
files:
(use "git add <file>..." to
include in what will be committed)
sampletextfile1.txt
user@user-PC MINGW32 /d/repository/localrepository
(master)
=>Now
commit the file in the local directory
staging
area to the local directory
user@user-PC MINGW32 /d/repository/localrepository
(master)
$
git commit -m "inital commit three file file1,file2,file3"
[master
(root-commit) e4e0f88] inital commit three file file1,file2,file3
3 files changed, 0 insertions(+), 0
deletions(-)
create mode 100644 file1.txt
create mode 100644 file2.txt
create mode 100644 file3.txt
user@user-PC MINGW32 /d/repository/localrepository
(master)
$
git status
On
branch master
Untracked
files:
(use "git add <file>..." to
include in what will be committed)
sampletextfile1.txt
nothing
added to commit but untracked files present (use "git add" to track)
=>check
log or commit history
user@user-PC MINGW32 /d/repository/localrepository
(master)
$
git log
commit e4e0f88666ad351749c12539a4a72cc5d86d08e3
Author:
virendra l <webveeru@gmail.com>
Date: Fri Sep 3 21:32:08 2021 +0530
inital commit three file file1,file2,file3
user@user-PC MINGW32 /d/repository/localrepository
(master)
Be patience
Continue to next blog Next blog

