ºÝºÝߣ

ºÝºÝߣShare a Scribd company logo
03/18/16 NOS Conf 2016
Version control system with git
and (github) as an example
Gaurav Garg
@gaurav_garg_
ggarg@redhat.com
freenode irc nic: ggarg
03/18/16 NOS Conf 2016
Agenda
?
VCS ¨C What is it ?
?
Why using a VCS is good idea
?
Git Basic including:
?How to obtain and install Git
?How to use it for basic/common operation
?More information resource for Git
?
Q & A
03/18/16 NOS Conf 2016
VCS What is it ?
? A way to keep track of changes to files or folders
? Keep record of changes why, what, when
? Non distributed system (subversion, CVS)
server has the master repo, all commit goes to the server
? Distributed (Git, mercurial)
server has the master repo, but you have copy of that repo
(clone) in your machine
03/18/16 NOS Conf 2016
Getting Git
?Dependencies:
* on a system that has yum (such as fedora)
$ yum install curl-devel expat-devel gettext-devel 
openssl-devel zlib-devel
* on a system that has apt-get (debian based system)
$ apt-get install libcurl4-gnutls-dev libexpat1-dev gettext 
libz-dev libssl-dev
03/18/16 NOS Conf 2016
Getting Git cont...
?Get the latest snapshot from git website:
http://git-scm.com/download
Then, compile and install:
$ tar -zxf git-1.7.2.2.tar.gz
$ cd git-1.7.2.2
$ make prefix=/usr/local all
$ sudo make prefix=/usr/local install
03/18/16 NOS Conf 2016
Getting Git cont...
? Binary Installer:
If you want to directly install binary then:
ª­ For Fedora:
$ yum install git
ª­ For debina based distribution:
$ apt-get install git
ª­ For mac
$ brew install git
03/18/16 NOS Conf 2016
Git basic operation
?Checking the installation:
Check if Git is installed
$ git - -version
git version 1.9.3
If not then follow the installation steps that mentioned in previous slides.
? Setting user name and email to your git config:
$ git config --global user.name "Gaurav Kumar Garg"
$ git config --global user.email " ggarg@redhat.com"
Note: If you want to set it for specific repositery then cd to that repositery and
Remove ¡°--global¡± option.
$ git config - -list command will verify user name and email address
03/18/16 NOS Conf 2016
Git basic operation cont...
? Obtaining a repository:
Creating a repository (if it does not exist remotely)
$ git init (follow http://git-scm.com/docs/git-init for more information)
Or cloning a remote repository:
git clone ssh://[username@]git.gluster.org/glusterfs.git glusterfs
For eg: cloning a gluserfs repository:
git clone ssh://ggarg@git.gluster.org/glusterfs.git glusterfs
here glusterfs is optional, which will be the name of repository.
Inspecting a repo: $ vim .git/config
03/18/16 NOS Conf 2016
Git basic operation cont...
? Inspecting repo:
$ git tag
will show you list of all tags (versioning of software)
$ git status
Difference b/w index file and current head commit
$ git log
Sow list of all commit with commit message
$ git log -1
Show top 1st commit
$ git log - -pretty=oneline
Show list of all commit in single line
03/18/16 NOS Conf 2016
Git basic operation cont...
? Making edit and commiting
? Edit your file with your fav editor (vim/emac etc.) and save it.
? $ git diff
will show delta difference code of current master HEAD and current index
? $ git status
will show path of file as ¡°Changes not staged for commit¡±
? $ git add (-A)
will show file as ¡°Changes to be commited¡±
? $ git commit -s
write your commit message. Save and exit.
* file changed, * insertion, * deletion (-)
? Check your commit by $ git log
03/18/16 NOS Conf 2016
Git basic operation cont...
? Recover your changes that you have added by
mistakes
$ git add <file name>
file <file name> that you have added by mistake
$ git status
$ git reset HEAD <filename>
$ git checkout - - <filename>
03/18/16 NOS Conf 2016
Git basic operation cont...
? Best pratice is to make seperate branch
$ git branch <branch name>
or
$ git checkout -b <branch name>
$ git branch -D <branch name>
will delete branch <branch name>
$ git branch -m <branch name> <new name>
will rename branch <branch name > with <new name>
03/18/16 NOS Conf 2016
Git basic operation cont...
? Git Stashing
Will allow you to save your changes without commiting them.
? $ git stash
save your change as a seperte stash@{*} branch with commit
message
? $ git stash list
will show you list of all stash with commit message
? $ git show <stash@{0}>
will show you what code difference contain this this stash@{0}
? $ git apply <stash@{0}>
will allow to apply change in current branch.
03/18/16 NOS Conf 2016
Git basic operation cont...
? Git rebase
forward-port local commit to local upstream master
? $ git rebase master
* will update your local commit with master
? $ git rebase -i HEAD~3
* will pick up top 3 commit and it
* can be use for reword, edit, squash commit
03/18/16 NOS Conf 2016
Git basic operation cont...
? Adding remote:
? $ git remote add <remote name> <remote_url>
Adding remote repo address in your local machine
user can add multiple remote repo address
? $ git remote -v
will show you list of all remote address with name
? $ git push <remote name> <branch name>
will push <branch name> change to remote address
03/18/16 NOS Conf 2016
Git basic operation cont...
? Git tagging
? $ git tag
* will list out all the tags (calles as versioning of
software)
? $ git tag -a <tag name> -m ¡°tag description¡±
* will give tag with tag name of tag version with
current branch HEAD
? $ git tag -d <tag name>
* Delete tag <tag name>
03/18/16 NOS Conf 2016
More information resource for Git
? $ git - -help
for eg: git - -help <rebase>
will give your help regarding ¡°git rebase¡±
? http://git-scm.com/docs/
contains resource of all git related command/operations.
03/18/16 NOS Conf 2016
Thank you....
03/18/16 NOS Conf 2016
Q/A

More Related Content

What's hot (20)

Git and GitHub workflows
Git and GitHub workflowsGit and GitHub workflows
Git and GitHub workflows
Arthur Shvetsov
?
Git tutorial
Git tutorialGit tutorial
Git tutorial
mobaires
?
Git commands
Git commandsGit commands
Git commands
Viyaan Jhiingade
?
Git basics
Git basicsGit basics
Git basics
Denys Haryachyy
?
Git intro hands on windows with msysgit
Git intro hands on windows with msysgitGit intro hands on windows with msysgit
Git intro hands on windows with msysgit
Geshan Manandhar
?
Version Control with Git
Version Control with GitVersion Control with Git
Version Control with Git
Luigi De Russis
?
Git tutorial
Git tutorial Git tutorial
Git tutorial
TingYen Lee
?
Git
GitGit
Git
Gayan Kalanamith Mannapperuma
?
Git presentation
Git presentationGit presentation
Git presentation
Vikas Yaligar
?
Git and fundamentals
Git and fundamentalsGit and fundamentals
Git and fundamentals
Naincy Gupta
?
Advanced Git Tutorial
Advanced Git TutorialAdvanced Git Tutorial
Advanced Git Tutorial
Sage Sharp
?
01 - Git vs SVN
01 - Git vs SVN01 - Git vs SVN
01 - Git vs SVN
Edward Goikhman
?
Advanced Git Presentation By Swawibe
Advanced Git Presentation By SwawibeAdvanced Git Presentation By Swawibe
Advanced Git Presentation By Swawibe
Md Swawibe Ul Alam
?
Extra bit with git
Extra bit with gitExtra bit with git
Extra bit with git
gdgjss
?
Git Tricks
Git TricksGit Tricks
Git Tricks
Ivelina Dimova
?
Git
GitGit
Git
Hanokh Aloni
?
Intro to Git DevOps Tally Presentation 101615
Intro to Git DevOps Tally Presentation 101615Intro to Git DevOps Tally Presentation 101615
Intro to Git DevOps Tally Presentation 101615
Brian K. Vagnini
?
Git vs svn
Git vs svnGit vs svn
Git vs svn
Suman Mukherjee
?
Extra bit with git
Extra bit with gitExtra bit with git
Extra bit with git
Himanshu Agrawal
?
Git - Get Ready To Use It
Git - Get Ready To Use ItGit - Get Ready To Use It
Git - Get Ready To Use It
Daniel Kummer
?

Similar to Version Control Systems with git (and github) as an example (20)

390a gitintro 12au
390a gitintro 12au390a gitintro 12au
390a gitintro 12au
Nguyen Van Hung
?
Understanding about git
Understanding about gitUnderstanding about git
Understanding about git
Sothearin Ren
?
sample.pptx
sample.pptxsample.pptx
sample.pptx
UshaSuray
?
Git and github 101
Git and github 101Git and github 101
Git and github 101
Senthilkumar Gopal
?
Git setuplinux
Git setuplinuxGit setuplinux
Git setuplinux
Shubham Verma
?
GitSetupLinux
GitSetupLinuxGitSetupLinux
GitSetupLinux
Shubham Verma
?
git-and-bitbucket
git-and-bitbucketgit-and-bitbucket
git-and-bitbucket
azwildcat
?
Getting some Git
Getting some GitGetting some Git
Getting some Git
BADR
?
GTFO: Git Theory For OpenSource
GTFO: Git Theory For OpenSourceGTFO: Git Theory For OpenSource
GTFO: Git Theory For OpenSource
Forest Mars
?
Basic git
Basic gitBasic git
Basic git
Casper Chen
?
Git
GitGit
Git
Terry Wang
?
Git ÈëÃÅÓëʵ¼ù
Git ÈëÃÅÓëʵ¼ùGit ÈëÃÅÓëʵ¼ù
Git ÈëÃÅÓëʵ¼ù
Terry Wang
?
Git ÈëÃÅ Óë ʵ¼ù
Git ÈëÃÅ Óë ʵ¼ùGit ÈëÃÅ Óë ʵ¼ù
Git ÈëÃÅ Óë ʵ¼ù
Terry Wang
?
Git walkthrough
Git walkthroughGit walkthrough
Git walkthrough
Mahmoud Said
?
Git session Dropsolid.com
Git session Dropsolid.comGit session Dropsolid.com
Git session Dropsolid.com
dropsolid
?
¼òµ¥½éÉܲµ¾±³Ù
¼òµ¥½éÉܲµ¾±³Ù¼òµ¥½éÉܲµ¾±³Ù
¼òµ¥½éÉܲµ¾±³Ù
Grace Chien
?
Working in Team using Git in Unity
Working in Team using Git in UnityWorking in Team using Git in Unity
Working in Team using Git in Unity
Rifauddin Tsalitsy
?
Introduction to Git and Github
Introduction to Git and Github Introduction to Git and Github
Introduction to Git and Github
Max Claus Nunes
?
Git and Github workshop GDSC MLRITM
Git and Github  workshop GDSC MLRITMGit and Github  workshop GDSC MLRITM
Git and Github workshop GDSC MLRITM
gdsc13
?
Exprimiendo GIT
Exprimiendo GITExprimiendo GIT
Exprimiendo GIT
betabeers
?
Understanding about git
Understanding about gitUnderstanding about git
Understanding about git
Sothearin Ren
?
git-and-bitbucket
git-and-bitbucketgit-and-bitbucket
git-and-bitbucket
azwildcat
?
Getting some Git
Getting some GitGetting some Git
Getting some Git
BADR
?
GTFO: Git Theory For OpenSource
GTFO: Git Theory For OpenSourceGTFO: Git Theory For OpenSource
GTFO: Git Theory For OpenSource
Forest Mars
?
Git ÈëÃÅÓëʵ¼ù
Git ÈëÃÅÓëʵ¼ùGit ÈëÃÅÓëʵ¼ù
Git ÈëÃÅÓëʵ¼ù
Terry Wang
?
Git ÈëÃÅ Óë ʵ¼ù
Git ÈëÃÅ Óë ʵ¼ùGit ÈëÃÅ Óë ʵ¼ù
Git ÈëÃÅ Óë ʵ¼ù
Terry Wang
?
Git session Dropsolid.com
Git session Dropsolid.comGit session Dropsolid.com
Git session Dropsolid.com
dropsolid
?
¼òµ¥½éÉܲµ¾±³Ù
¼òµ¥½éÉܲµ¾±³Ù¼òµ¥½éÉܲµ¾±³Ù
¼òµ¥½éÉܲµ¾±³Ù
Grace Chien
?
Working in Team using Git in Unity
Working in Team using Git in UnityWorking in Team using Git in Unity
Working in Team using Git in Unity
Rifauddin Tsalitsy
?
Introduction to Git and Github
Introduction to Git and Github Introduction to Git and Github
Introduction to Git and Github
Max Claus Nunes
?
Git and Github workshop GDSC MLRITM
Git and Github  workshop GDSC MLRITMGit and Github  workshop GDSC MLRITM
Git and Github workshop GDSC MLRITM
gdsc13
?
Exprimiendo GIT
Exprimiendo GITExprimiendo GIT
Exprimiendo GIT
betabeers
?

Recently uploaded (20)

Fast Screen Recorder v2.1.0.11 Crack Updated [April-2025]
Fast Screen Recorder v2.1.0.11 Crack Updated [April-2025]Fast Screen Recorder v2.1.0.11 Crack Updated [April-2025]
Fast Screen Recorder v2.1.0.11 Crack Updated [April-2025]
jackalen173
?
San Francisco Atlassian ACE - Mar 27 2025.pdf
San Francisco Atlassian ACE - Mar 27 2025.pdfSan Francisco Atlassian ACE - Mar 27 2025.pdf
San Francisco Atlassian ACE - Mar 27 2025.pdf
Matt Doar
?
Packaging your App for AppExchange ¨C Managed Vs Unmanaged.pptx
Packaging your App for AppExchange ¨C Managed Vs Unmanaged.pptxPackaging your App for AppExchange ¨C Managed Vs Unmanaged.pptx
Packaging your App for AppExchange ¨C Managed Vs Unmanaged.pptx
mohayyudin7826
?
Network_Packet_Brokers_Presentation.pptx
Network_Packet_Brokers_Presentation.pptxNetwork_Packet_Brokers_Presentation.pptx
Network_Packet_Brokers_Presentation.pptx
Khushi Communications
?
State_of_AI_Transformation in Germany.pdf
State_of_AI_Transformation in Germany.pdfState_of_AI_Transformation in Germany.pdf
State_of_AI_Transformation in Germany.pdf
VaradRajanKrishna
?
APAC Solutions Challenge Info Session.pdf
APAC Solutions Challenge Info Session.pdfAPAC Solutions Challenge Info Session.pdf
APAC Solutions Challenge Info Session.pdf
GDG on Campus Monash
?
CIOs Speak Out - A Research Series by Jasper Colin
CIOs Speak Out - A Research Series by Jasper ColinCIOs Speak Out - A Research Series by Jasper Colin
CIOs Speak Out - A Research Series by Jasper Colin
Jasper Colin
?
Microsoft Digital Defense Report 2024 .pdf
Microsoft Digital Defense Report 2024 .pdfMicrosoft Digital Defense Report 2024 .pdf
Microsoft Digital Defense Report 2024 .pdf
Abhishek Agarwal
?
Leadership Spectrum by Sonam Sherpa at GDG Kathmandu March Monthly Meetup
Leadership Spectrum by Sonam Sherpa at GDG Kathmandu March Monthly MeetupLeadership Spectrum by Sonam Sherpa at GDG Kathmandu March Monthly Meetup
Leadership Spectrum by Sonam Sherpa at GDG Kathmandu March Monthly Meetup
GDG Kathmandu
?
A General introduction to Ad ranking algorithms
A General introduction to Ad ranking algorithmsA General introduction to Ad ranking algorithms
A General introduction to Ad ranking algorithms
Buhwan Jeong
?
Testing Tools for Accessibility Enhancement Part II.pptx
Testing Tools for Accessibility Enhancement Part II.pptxTesting Tools for Accessibility Enhancement Part II.pptx
Testing Tools for Accessibility Enhancement Part II.pptx
Julia Undeutsch
?
Automated Engineering of Domain-Specific Metamorphic Testing Environments
Automated Engineering of Domain-Specific Metamorphic Testing EnvironmentsAutomated Engineering of Domain-Specific Metamorphic Testing Environments
Automated Engineering of Domain-Specific Metamorphic Testing Environments
Pablo G¨®mez Abajo
?
Innovative Web Design | Malachite Technologies
Innovative Web Design | Malachite TechnologiesInnovative Web Design | Malachite Technologies
Innovative Web Design | Malachite Technologies
malachitetechnologie1
?
Beyond the life of a CISO - Head of Trust at GDG Kathmandu Monthly Meetup
Beyond the life of a CISO -  Head of Trust at GDG Kathmandu Monthly MeetupBeyond the life of a CISO -  Head of Trust at GDG Kathmandu Monthly Meetup
Beyond the life of a CISO - Head of Trust at GDG Kathmandu Monthly Meetup
GDG Kathmandu
?
Columbia Weather Systems - Product Overview
Columbia Weather Systems - Product OverviewColumbia Weather Systems - Product Overview
Columbia Weather Systems - Product Overview
Columbia Weather Systems
?
202408_JAWSPANKRATION_Introduction_of_Minaden.pdf
202408_JAWSPANKRATION_Introduction_of_Minaden.pdf202408_JAWSPANKRATION_Introduction_of_Minaden.pdf
202408_JAWSPANKRATION_Introduction_of_Minaden.pdf
NTTDOCOMO-ServiceInnovation
?
AI in Talent Acquisition: Boosting Hiring
AI in Talent Acquisition: Boosting HiringAI in Talent Acquisition: Boosting Hiring
AI in Talent Acquisition: Boosting Hiring
Beyond Chiefs
?
Getting the Best of TrueDEM ¨C April News & Updates
Getting the Best of TrueDEM ¨C April News & UpdatesGetting the Best of TrueDEM ¨C April News & Updates
Getting the Best of TrueDEM ¨C April News & Updates
panagenda
?
HHUG-04-2025-Close-more-deals-from-your-existing-pipeline-FOR SLIDESHARE.pptx
HHUG-04-2025-Close-more-deals-from-your-existing-pipeline-FOR SLIDESHARE.pptxHHUG-04-2025-Close-more-deals-from-your-existing-pipeline-FOR SLIDESHARE.pptx
HHUG-04-2025-Close-more-deals-from-your-existing-pipeline-FOR SLIDESHARE.pptx
HampshireHUG
?
The Road to SAP S4HANA Cloud with SAP Activate.pptx
The Road to SAP S4HANA Cloud with SAP Activate.pptxThe Road to SAP S4HANA Cloud with SAP Activate.pptx
The Road to SAP S4HANA Cloud with SAP Activate.pptx
zsbaranyai
?
Fast Screen Recorder v2.1.0.11 Crack Updated [April-2025]
Fast Screen Recorder v2.1.0.11 Crack Updated [April-2025]Fast Screen Recorder v2.1.0.11 Crack Updated [April-2025]
Fast Screen Recorder v2.1.0.11 Crack Updated [April-2025]
jackalen173
?
San Francisco Atlassian ACE - Mar 27 2025.pdf
San Francisco Atlassian ACE - Mar 27 2025.pdfSan Francisco Atlassian ACE - Mar 27 2025.pdf
San Francisco Atlassian ACE - Mar 27 2025.pdf
Matt Doar
?
Packaging your App for AppExchange ¨C Managed Vs Unmanaged.pptx
Packaging your App for AppExchange ¨C Managed Vs Unmanaged.pptxPackaging your App for AppExchange ¨C Managed Vs Unmanaged.pptx
Packaging your App for AppExchange ¨C Managed Vs Unmanaged.pptx
mohayyudin7826
?
State_of_AI_Transformation in Germany.pdf
State_of_AI_Transformation in Germany.pdfState_of_AI_Transformation in Germany.pdf
State_of_AI_Transformation in Germany.pdf
VaradRajanKrishna
?
APAC Solutions Challenge Info Session.pdf
APAC Solutions Challenge Info Session.pdfAPAC Solutions Challenge Info Session.pdf
APAC Solutions Challenge Info Session.pdf
GDG on Campus Monash
?
CIOs Speak Out - A Research Series by Jasper Colin
CIOs Speak Out - A Research Series by Jasper ColinCIOs Speak Out - A Research Series by Jasper Colin
CIOs Speak Out - A Research Series by Jasper Colin
Jasper Colin
?
Microsoft Digital Defense Report 2024 .pdf
Microsoft Digital Defense Report 2024 .pdfMicrosoft Digital Defense Report 2024 .pdf
Microsoft Digital Defense Report 2024 .pdf
Abhishek Agarwal
?
Leadership Spectrum by Sonam Sherpa at GDG Kathmandu March Monthly Meetup
Leadership Spectrum by Sonam Sherpa at GDG Kathmandu March Monthly MeetupLeadership Spectrum by Sonam Sherpa at GDG Kathmandu March Monthly Meetup
Leadership Spectrum by Sonam Sherpa at GDG Kathmandu March Monthly Meetup
GDG Kathmandu
?
A General introduction to Ad ranking algorithms
A General introduction to Ad ranking algorithmsA General introduction to Ad ranking algorithms
A General introduction to Ad ranking algorithms
Buhwan Jeong
?
Testing Tools for Accessibility Enhancement Part II.pptx
Testing Tools for Accessibility Enhancement Part II.pptxTesting Tools for Accessibility Enhancement Part II.pptx
Testing Tools for Accessibility Enhancement Part II.pptx
Julia Undeutsch
?
Automated Engineering of Domain-Specific Metamorphic Testing Environments
Automated Engineering of Domain-Specific Metamorphic Testing EnvironmentsAutomated Engineering of Domain-Specific Metamorphic Testing Environments
Automated Engineering of Domain-Specific Metamorphic Testing Environments
Pablo G¨®mez Abajo
?
Innovative Web Design | Malachite Technologies
Innovative Web Design | Malachite TechnologiesInnovative Web Design | Malachite Technologies
Innovative Web Design | Malachite Technologies
malachitetechnologie1
?
Beyond the life of a CISO - Head of Trust at GDG Kathmandu Monthly Meetup
Beyond the life of a CISO -  Head of Trust at GDG Kathmandu Monthly MeetupBeyond the life of a CISO -  Head of Trust at GDG Kathmandu Monthly Meetup
Beyond the life of a CISO - Head of Trust at GDG Kathmandu Monthly Meetup
GDG Kathmandu
?
AI in Talent Acquisition: Boosting Hiring
AI in Talent Acquisition: Boosting HiringAI in Talent Acquisition: Boosting Hiring
AI in Talent Acquisition: Boosting Hiring
Beyond Chiefs
?
Getting the Best of TrueDEM ¨C April News & Updates
Getting the Best of TrueDEM ¨C April News & UpdatesGetting the Best of TrueDEM ¨C April News & Updates
Getting the Best of TrueDEM ¨C April News & Updates
panagenda
?
HHUG-04-2025-Close-more-deals-from-your-existing-pipeline-FOR SLIDESHARE.pptx
HHUG-04-2025-Close-more-deals-from-your-existing-pipeline-FOR SLIDESHARE.pptxHHUG-04-2025-Close-more-deals-from-your-existing-pipeline-FOR SLIDESHARE.pptx
HHUG-04-2025-Close-more-deals-from-your-existing-pipeline-FOR SLIDESHARE.pptx
HampshireHUG
?
The Road to SAP S4HANA Cloud with SAP Activate.pptx
The Road to SAP S4HANA Cloud with SAP Activate.pptxThe Road to SAP S4HANA Cloud with SAP Activate.pptx
The Road to SAP S4HANA Cloud with SAP Activate.pptx
zsbaranyai
?

Version Control Systems with git (and github) as an example

  • 1. 03/18/16 NOS Conf 2016 Version control system with git and (github) as an example Gaurav Garg @gaurav_garg_ ggarg@redhat.com freenode irc nic: ggarg
  • 2. 03/18/16 NOS Conf 2016 Agenda ? VCS ¨C What is it ? ? Why using a VCS is good idea ? Git Basic including: ?How to obtain and install Git ?How to use it for basic/common operation ?More information resource for Git ? Q & A
  • 3. 03/18/16 NOS Conf 2016 VCS What is it ? ? A way to keep track of changes to files or folders ? Keep record of changes why, what, when ? Non distributed system (subversion, CVS) server has the master repo, all commit goes to the server ? Distributed (Git, mercurial) server has the master repo, but you have copy of that repo (clone) in your machine
  • 4. 03/18/16 NOS Conf 2016 Getting Git ?Dependencies: * on a system that has yum (such as fedora) $ yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel * on a system that has apt-get (debian based system) $ apt-get install libcurl4-gnutls-dev libexpat1-dev gettext libz-dev libssl-dev
  • 5. 03/18/16 NOS Conf 2016 Getting Git cont... ?Get the latest snapshot from git website: http://git-scm.com/download Then, compile and install: $ tar -zxf git-1.7.2.2.tar.gz $ cd git-1.7.2.2 $ make prefix=/usr/local all $ sudo make prefix=/usr/local install
  • 6. 03/18/16 NOS Conf 2016 Getting Git cont... ? Binary Installer: If you want to directly install binary then: ª­ For Fedora: $ yum install git ª­ For debina based distribution: $ apt-get install git ª­ For mac $ brew install git
  • 7. 03/18/16 NOS Conf 2016 Git basic operation ?Checking the installation: Check if Git is installed $ git - -version git version 1.9.3 If not then follow the installation steps that mentioned in previous slides. ? Setting user name and email to your git config: $ git config --global user.name "Gaurav Kumar Garg" $ git config --global user.email " ggarg@redhat.com" Note: If you want to set it for specific repositery then cd to that repositery and Remove ¡°--global¡± option. $ git config - -list command will verify user name and email address
  • 8. 03/18/16 NOS Conf 2016 Git basic operation cont... ? Obtaining a repository: Creating a repository (if it does not exist remotely) $ git init (follow http://git-scm.com/docs/git-init for more information) Or cloning a remote repository: git clone ssh://[username@]git.gluster.org/glusterfs.git glusterfs For eg: cloning a gluserfs repository: git clone ssh://ggarg@git.gluster.org/glusterfs.git glusterfs here glusterfs is optional, which will be the name of repository. Inspecting a repo: $ vim .git/config
  • 9. 03/18/16 NOS Conf 2016 Git basic operation cont... ? Inspecting repo: $ git tag will show you list of all tags (versioning of software) $ git status Difference b/w index file and current head commit $ git log Sow list of all commit with commit message $ git log -1 Show top 1st commit $ git log - -pretty=oneline Show list of all commit in single line
  • 10. 03/18/16 NOS Conf 2016 Git basic operation cont... ? Making edit and commiting ? Edit your file with your fav editor (vim/emac etc.) and save it. ? $ git diff will show delta difference code of current master HEAD and current index ? $ git status will show path of file as ¡°Changes not staged for commit¡± ? $ git add (-A) will show file as ¡°Changes to be commited¡± ? $ git commit -s write your commit message. Save and exit. * file changed, * insertion, * deletion (-) ? Check your commit by $ git log
  • 11. 03/18/16 NOS Conf 2016 Git basic operation cont... ? Recover your changes that you have added by mistakes $ git add <file name> file <file name> that you have added by mistake $ git status $ git reset HEAD <filename> $ git checkout - - <filename>
  • 12. 03/18/16 NOS Conf 2016 Git basic operation cont... ? Best pratice is to make seperate branch $ git branch <branch name> or $ git checkout -b <branch name> $ git branch -D <branch name> will delete branch <branch name> $ git branch -m <branch name> <new name> will rename branch <branch name > with <new name>
  • 13. 03/18/16 NOS Conf 2016 Git basic operation cont... ? Git Stashing Will allow you to save your changes without commiting them. ? $ git stash save your change as a seperte stash@{*} branch with commit message ? $ git stash list will show you list of all stash with commit message ? $ git show <stash@{0}> will show you what code difference contain this this stash@{0} ? $ git apply <stash@{0}> will allow to apply change in current branch.
  • 14. 03/18/16 NOS Conf 2016 Git basic operation cont... ? Git rebase forward-port local commit to local upstream master ? $ git rebase master * will update your local commit with master ? $ git rebase -i HEAD~3 * will pick up top 3 commit and it * can be use for reword, edit, squash commit
  • 15. 03/18/16 NOS Conf 2016 Git basic operation cont... ? Adding remote: ? $ git remote add <remote name> <remote_url> Adding remote repo address in your local machine user can add multiple remote repo address ? $ git remote -v will show you list of all remote address with name ? $ git push <remote name> <branch name> will push <branch name> change to remote address
  • 16. 03/18/16 NOS Conf 2016 Git basic operation cont... ? Git tagging ? $ git tag * will list out all the tags (calles as versioning of software) ? $ git tag -a <tag name> -m ¡°tag description¡± * will give tag with tag name of tag version with current branch HEAD ? $ git tag -d <tag name> * Delete tag <tag name>
  • 17. 03/18/16 NOS Conf 2016 More information resource for Git ? $ git - -help for eg: git - -help <rebase> will give your help regarding ¡°git rebase¡± ? http://git-scm.com/docs/ contains resource of all git related command/operations.
  • 18. 03/18/16 NOS Conf 2016 Thank you....
  • 19. 03/18/16 NOS Conf 2016 Q/A