SlideShare a Scribd company logo
git for beginners
Arulmurugan
@arulmrr
www.indjango.com
git
● Source code management software
● DVCS (Distributed Version Control System)
● hg - Similar tool
● CVS, Bazaar, SVN
Installation
● Ubuntu
sudo apt-get install git
● Windows
Ubuntu and Windows
● Commands here can be executed in the
respective OS as defined below
● Ubuntu
○ Can use their system terminal
● Windows
○ Select git bash in your Right-click context menu
git Hosting
Bitbucket Github
Unlimited public and private repositories Unlimited Public repositories
Cost based on number of users Cost based on number of repositories
Supports git and hg Supports git only
● Codeplane, Githost, Assembla, Cloudforge, Gitorious
● Bitbucket
Username - arulmurugan
E-Mail - arulmurugan@example.com
ssh-key Setup
● ssh-keygen #Command to generate public key
● Copy contents of id_rsa.pub
Bitbucket - Create Repo
An empty repo
Repo - User Management
● To manage who access your repository
Git configuration
Basic Configurations:
● git config --global user.name "second_user_name"
● git config --global user.email "second_user_email"
● git config --global push.default "matching"
● git config --global color.status auto
● git config --global color.branch auto
● git config --list
Optional Configurations:
● git config --global branch.master.remote origin
● git config --global branch.master.merge refs/heads/master
.gitignore
● Can be configured to ignore certain files and
directories
● Git ignores empty directories by default
My first repo
● cd ~/git/myproject/
#Open your project directory in terminal
● git init
#Initiating a git repository
● git remote add origin git@bitbucket.org:arulmurugan/dummy.git
#Adding remote repository URL
● git add .
#Adding files to be committed
● git commit -m "Initial commit"
#Committing the added files and changes
● git push origin master
#Pushing the commits to remote repository
Repo with Initial commit
git status
● Will show the list changed and new files
which are yet to be committed
git add & git commit
● git add .
#To add all untracked files
● git add test2.html
#To add specific files
● git commit -am "commit message"
#To commit all changed files
● git commit -m "commit message" test1.html
#To commit specific files
git add & git commit (Contd...)
Bitbucket - Source and Commits
git pull
● To pull changes pushed by other users from
remote repo to local repo
Merge conflicts
● A merge conflicts occurs, if two people have
modified the same content.
git mergetool
● http://meldmerge.org/
Status and History
● git diff
#Shows differences in uncommitted files / last commit
● git log
#Shows history of commits in the current branch
● git log --oneline --abbrev-commit
#Shows one line commit history with short commit id
● git log --graph --pretty --oneline --abbrev-commit
#Shows the history as graph
● git diff-tree --name-only -r <commit_id>
#Shows files changed in the commit
● git show <commit_id>
#Shows changes in the commit
History of file
● git log [filename]
#Shows commits for the file
● git log -p [filename]
#Shows commits for the file with changes
● git log --follow -p [filename]
#Shows commits for the file including renames
● git blame [filename]
#Shows author and commit per line of the file
● git blame -L 1,3 [filename]
#Shows author and commit from line 2 to line 3
● git commit --amend -m "More changes - now correct"
#To amend changes to previous commit before pushing
Remote repositories
● git remote
#Show the existing remote repos
● git remote show origin
#Show the details of remote repo origin
● git clone git@bitbucket.org:arulmurugan/dummy.git
#To clone remote repository
git stash
● Allows to save the current uncommitted
changes and checkout the last committed
revision.
● Allows you to pull in the latest changes
without conflicts.
● Afterwards you can restore the stashed
changes, which will apply the changes to the
current version of the source code.
git stash (Contd...)
● git stash save "stash message"
#To save uncommited changes as stash
● git stash list
#To view list of saved stashes
#stash@{0}: On master: Title changed
● git stash apply stash@{0}
#To apply the particular stash
● git stash drop stash@{0}
#To drop particular stash
● git stash clear
#To drop all saved stashes
● git stash pop
#To apply most recent stash and delete it from list of stashes
git stash (Contd...)
Reverting changes
● git clean - To remove newly added files
○ git clean -n
#To see what would happen
○ git clean -f
#To remove the files
● git checkout - To revert changed and deleted files
○ git checkout .
#To revert all changed files
○ git checkout [filename]
#To restore or revert the file
○ git checkout <commit_id>
#To checkout a particular commit
Reverting changes (Contd...)
● git reset [filename]
#To remove a file added by git add before pushing
● git checkout HEAD -- [dir_name]
#To recover an accidentally deleted directory in repo
● git revert <commit_id>
#To revert a particular commit
● git reset --hard HEAD~1
#To delete last 1 commit
● git reset --hard <sha1-commit-id>
#To delete upto a particular commit
● git push -f
#Push with force to push commit deletions
Reverting changes (Contd...)
● git reflog
#Shows a history of the complete changes of your
current branch based on the HEAD revision
● git reset --hard <commit_id>
#To revert to a commit shown in git reflog
Branches
● Branches are copies of the files from a certain
commit and they can be changed independently
from each other.
● The default branch is called master.
● Untracked files remain unchanged and are
available in the new branch. This allows you to
create a branch for unstaged and uncommitted
changes at any point in time.
Branches (Contd...)
● git branch
#List available branches
● git branch -a
#List available branches including remote branches
● git branch -r
#List remote branches only
● git branch <branch_name>
#To create new branch
● git checkout <branch_name>
#To switch to a branch
● git checkout -b <branch_name>
#To create a branch and switch to it
Branches (Contd...)
● git checkout -b <branch_name> master~1
#Create a new branch based on master without last commit
● git branch -d <branch_name>
#To delete a branch
● git push origin <branch_name>
#To push branch to remote
● git push origin --delete <branch_name>
#To delete a remote branch
● git checkout -b <branch_name> origin/<branch_name>
#To create a tracking branch
● git merge <branch_name>
#To merge specified branch with current branch
Retrieving files
● git show [reference]:[filename]
#To see contents of a file
# [reference] can be a branch, tag, HEAD or commit ID
● git show [reference]:[filename] > [filename_copy]
#To copy a file
● git log -- [filename]
#To see commit history of a file, even if deleted
Alias
● Allows you to setup your own git command
● git config --global alias.st 'git status'
#Set command "st" for git status
#Now git st can be used instead of git status
● git config --global alias.acm '!git add . -A && git commit'
#Set command "acm" for git add . and git commit
#Now you can use git acm "message" for commits
#Not supported in windows*
Submodules - Repos inside repos
● Allows you to include another Git repository
into a Git repository
● git submodule add [URL to Git repo]
#To add submodule to your repo
● After cloning a repo with submodules
○ git submodule init
#Creates local configuration file for submodules
○ git submodule update
#To clone submodules
● Rebase
● Patches
● Git server
Missed Out:
References:
1. http://www.vogella.com/articles/Git/article.html
2. http://git-scm.com/book/
3. http://www.kernel.org/pub/software/scm/git/docs/
Thank you
arul@indjango.com

More Related Content

What's hot

Git - An Introduction
Git - An IntroductionGit - An Introduction
Git - An Introduction
Behzad Altaf
 
Introduction git
Introduction gitIntroduction git
Introduction git
Dian Sigit Prastowo
 
Git in 10 minutes
Git in 10 minutesGit in 10 minutes
Git in 10 minutes
Safique Ahmed Faruque
 
Intro to git and git hub
Intro to git and git hubIntro to git and git hub
Intro to git and git hub
Venkat Malladi
 
Basic Git Intro
Basic Git IntroBasic Git Intro
Basic Git Intro
Yoad Snapir
 
git and github
git and githubgit and github
git and github
Darren Oakley
 
Git and Github Session
Git and Github SessionGit and Github Session
Git and Github Session
GoogleDevelopersStud1
 
Git basics to advance with diagrams
Git basics to advance with diagramsGit basics to advance with diagrams
Git basics to advance with diagrams
Dilum Navanjana
 
Starting with Git & GitHub
Starting with Git & GitHubStarting with Git & GitHub
Starting with Git & GitHub
Nicolás Tourné
 
Introduction to Git and Github
Introduction to Git and GithubIntroduction to Git and Github
Introduction to Git and Github
Roland Emmanuel Salunga
 
The everyday developer's guide to version control with Git
The everyday developer's guide to version control with GitThe everyday developer's guide to version control with Git
The everyday developer's guide to version control with Git
E Carter
 
Git and github
Git and githubGit and github
Git and github
Sayantika Banik
 
Git basic
Git basicGit basic
Git basic
Emran Ul Hadi
 
A Practical Introduction to git
A Practical Introduction to gitA Practical Introduction to git
A Practical Introduction to git
Emanuele Olivetti
 
Git n git hub
Git n git hubGit n git hub
Git n git hub
Jiwon Baek
 
Introduction to git & GitHub
Introduction to git & GitHubIntroduction to git & GitHub
Introduction to git & GitHub
Poornachandrakashi
 
Introduction to Git
Introduction to GitIntroduction to Git
Introduction to Git
Lukas Fittl
 
Github - Git Training Slides: Foundations
Github - Git Training Slides: FoundationsGithub - Git Training Slides: Foundations
Github - Git Training Slides: Foundations
Lee Hanxue
 
Git and GitHub | Concept about Git and GitHub Process | Git Process overview
Git and GitHub | Concept about Git and GitHub Process | Git Process overviewGit and GitHub | Concept about Git and GitHub Process | Git Process overview
Git and GitHub | Concept about Git and GitHub Process | Git Process overview
Rueful Robin
 

What's hot (20)

Git - An Introduction
Git - An IntroductionGit - An Introduction
Git - An Introduction
 
Introduction git
Introduction gitIntroduction git
Introduction git
 
Git in 10 minutes
Git in 10 minutesGit in 10 minutes
Git in 10 minutes
 
Intro to git and git hub
Intro to git and git hubIntro to git and git hub
Intro to git and git hub
 
Basic Git Intro
Basic Git IntroBasic Git Intro
Basic Git Intro
 
git and github
git and githubgit and github
git and github
 
Git and Github Session
Git and Github SessionGit and Github Session
Git and Github Session
 
Git real slides
Git real slidesGit real slides
Git real slides
 
Git basics to advance with diagrams
Git basics to advance with diagramsGit basics to advance with diagrams
Git basics to advance with diagrams
 
Starting with Git & GitHub
Starting with Git & GitHubStarting with Git & GitHub
Starting with Git & GitHub
 
Introduction to Git and Github
Introduction to Git and GithubIntroduction to Git and Github
Introduction to Git and Github
 
The everyday developer's guide to version control with Git
The everyday developer's guide to version control with GitThe everyday developer's guide to version control with Git
The everyday developer's guide to version control with Git
 
Git and github
Git and githubGit and github
Git and github
 
Git basic
Git basicGit basic
Git basic
 
A Practical Introduction to git
A Practical Introduction to gitA Practical Introduction to git
A Practical Introduction to git
 
Git n git hub
Git n git hubGit n git hub
Git n git hub
 
Introduction to git & GitHub
Introduction to git & GitHubIntroduction to git & GitHub
Introduction to git & GitHub
 
Introduction to Git
Introduction to GitIntroduction to Git
Introduction to Git
 
Github - Git Training Slides: Foundations
Github - Git Training Slides: FoundationsGithub - Git Training Slides: Foundations
Github - Git Training Slides: Foundations
 
Git and GitHub | Concept about Git and GitHub Process | Git Process overview
Git and GitHub | Concept about Git and GitHub Process | Git Process overviewGit and GitHub | Concept about Git and GitHub Process | Git Process overview
Git and GitHub | Concept about Git and GitHub Process | Git Process overview
 

Viewers also liked

Git 101: Git and GitHub for Beginners
Git 101: Git and GitHub for Beginners Git 101: Git and GitHub for Beginners
Git 101: Git and GitHub for Beginners
HubSpot
 
Quick Introduction to git
Quick Introduction to gitQuick Introduction to git
Quick Introduction to gitJoel Krebs
 
Git 101 - Crash Course in Version Control using Git
Git 101 - Crash Course in Version Control using GitGit 101 - Crash Course in Version Control using Git
Git 101 - Crash Course in Version Control using Git
Geoff Hoffman
 
How to become a Git power user
How to become a Git power userHow to become a Git power user
How to become a Git power user
Deveo
 
Git in pills : git stash
Git in pills : git stashGit in pills : git stash
Git in pills : git stash
Federico Panini
 
Git & e git beginner workshop
Git & e git beginner workshopGit & e git beginner workshop
Git & e git beginner workshop
Igor Laborie
 
Git for the absolute beginners
Git for the absolute beginnersGit for the absolute beginners
Git for the absolute beginners
Gabriele Baldassarre
 
Git & Github for beginners
Git & Github for beginnersGit & Github for beginners
Git & Github for beginners
Paulo Henrique Nonaka
 
Git 101 tutorial presentation
Git 101 tutorial presentationGit 101 tutorial presentation
Git 101 tutorial presentationTerry Wang
 
Django in Eclipse
Django in EclipseDjango in Eclipse
Django in Eclipse
Arulmurugan Rajaraman
 
Git tutorial
Git tutorialGit tutorial
Git tutorial
Elli Kanal
 
Git essentials
Git essentialsGit essentials
Git essentials
Matthew Barlocker
 
Introduction to Continuous Integration with Jenkins
Introduction to Continuous Integration with JenkinsIntroduction to Continuous Integration with Jenkins
Introduction to Continuous Integration with Jenkins
Eric Hogue
 
Ci jenkins maven svn
Ci jenkins maven svnCi jenkins maven svn
Ci jenkins maven svn
Ankur Goyal
 
Git physiology ga
Git physiology  gaGit physiology  ga
Git physiology ga
Gulfam AHMAD CH
 
Gastrointestinal mcq
Gastrointestinal mcqGastrointestinal mcq
Gastrointestinal mcq
Rashed Hassen
 
Introduction to systems programming
Introduction to systems programmingIntroduction to systems programming
Introduction to systems programming
Mukesh Tekwani
 
System Programming Unit III
System Programming Unit IIISystem Programming Unit III
System Programming Unit IIIManoj Patil
 

Viewers also liked (20)

Git 101: Git and GitHub for Beginners
Git 101: Git and GitHub for Beginners Git 101: Git and GitHub for Beginners
Git 101: Git and GitHub for Beginners
 
Quick Introduction to git
Quick Introduction to gitQuick Introduction to git
Quick Introduction to git
 
Git tutorial
Git tutorial Git tutorial
Git tutorial
 
Git 101 - Crash Course in Version Control using Git
Git 101 - Crash Course in Version Control using GitGit 101 - Crash Course in Version Control using Git
Git 101 - Crash Course in Version Control using Git
 
How to become a Git power user
How to become a Git power userHow to become a Git power user
How to become a Git power user
 
Git in pills : git stash
Git in pills : git stashGit in pills : git stash
Git in pills : git stash
 
Git & e git beginner workshop
Git & e git beginner workshopGit & e git beginner workshop
Git & e git beginner workshop
 
Git for beginners
Git for beginnersGit for beginners
Git for beginners
 
Git for the absolute beginners
Git for the absolute beginnersGit for the absolute beginners
Git for the absolute beginners
 
Git & Github for beginners
Git & Github for beginnersGit & Github for beginners
Git & Github for beginners
 
Git 101 tutorial presentation
Git 101 tutorial presentationGit 101 tutorial presentation
Git 101 tutorial presentation
 
Django in Eclipse
Django in EclipseDjango in Eclipse
Django in Eclipse
 
Git tutorial
Git tutorialGit tutorial
Git tutorial
 
Git essentials
Git essentialsGit essentials
Git essentials
 
Introduction to Continuous Integration with Jenkins
Introduction to Continuous Integration with JenkinsIntroduction to Continuous Integration with Jenkins
Introduction to Continuous Integration with Jenkins
 
Ci jenkins maven svn
Ci jenkins maven svnCi jenkins maven svn
Ci jenkins maven svn
 
Git physiology ga
Git physiology  gaGit physiology  ga
Git physiology ga
 
Gastrointestinal mcq
Gastrointestinal mcqGastrointestinal mcq
Gastrointestinal mcq
 
Introduction to systems programming
Introduction to systems programmingIntroduction to systems programming
Introduction to systems programming
 
System Programming Unit III
System Programming Unit IIISystem Programming Unit III
System Programming Unit III
 

Similar to Git for beginners

Pro git - grasping it conceptually
Pro git - grasping it conceptuallyPro git - grasping it conceptually
Pro git - grasping it conceptually
seungzzang Kim
 
Essential Git and Github commands
Essential Git and Github commandsEssential Git and Github commands
Essential Git and Github commands
Isham Rashik
 
GIT_GITHUB_2016_06_17
GIT_GITHUB_2016_06_17GIT_GITHUB_2016_06_17
GIT_GITHUB_2016_06_17siva ram
 
Git tech talk
Git tech talkGit tech talk
Git tech talkrazasayed
 
Git cheat-sheet 2021
Git cheat-sheet 2021Git cheat-sheet 2021
Git cheat-sheet 2021
Rana Faisal Haroon
 
Git cheat-sheet
Git cheat-sheetGit cheat-sheet
Git cheat-sheet
MarcoRodas9
 
Getting some Git
Getting some GitGetting some Git
Getting some Git
BADR
 
Git and git workflow best practice
Git and git workflow best practiceGit and git workflow best practice
Git and git workflow best practice
Majid Hosseini
 
Git Intermediate Course
Git Intermediate CourseGit Intermediate Course
Git Intermediate Course
Ali Abbasi
 
Git and GitHub
Git and GitHubGit and GitHub
Git and GitHub
Priya Nayak
 
Git Memento of basic commands
Git Memento of basic commandsGit Memento of basic commands
Git Memento of basic commands
Zakaria Bouazza
 
Introduction to GIT
Introduction to GITIntroduction to GIT
Introduction to GIT
Piotr Benetkiewicz
 
Git commands
Git commandsGit commands
Git commands
Viyaan Jhiingade
 
Hacktoberfest intro to Git and GitHub
Hacktoberfest intro to Git and GitHubHacktoberfest intro to Git and GitHub
Hacktoberfest intro to Git and GitHub
DSC GVP
 
How to git easily in day to-day work
How to git easily in day to-day workHow to git easily in day to-day work
How to git easily in day to-day work
Alena Radkevich
 
Git 入门与实践
Git 入门与实践Git 入门与实践
Git 入门与实践Terry Wang
 
Git 入门 与 实践
Git 入门 与 实践Git 入门 与 实践
Git 入门 与 实践Terry Wang
 
The Fundamentals of Git
The Fundamentals of GitThe Fundamentals of Git
The Fundamentals of Git
DivineOmega
 

Similar to Git for beginners (20)

Pro git - grasping it conceptually
Pro git - grasping it conceptuallyPro git - grasping it conceptually
Pro git - grasping it conceptually
 
Essential Git and Github commands
Essential Git and Github commandsEssential Git and Github commands
Essential Git and Github commands
 
GIT_GITHUB_2016_06_17
GIT_GITHUB_2016_06_17GIT_GITHUB_2016_06_17
GIT_GITHUB_2016_06_17
 
Git tech talk
Git tech talkGit tech talk
Git tech talk
 
Git cheat-sheet 2021
Git cheat-sheet 2021Git cheat-sheet 2021
Git cheat-sheet 2021
 
Git cheat-sheet
Git cheat-sheetGit cheat-sheet
Git cheat-sheet
 
Getting some Git
Getting some GitGetting some Git
Getting some Git
 
Git and git workflow best practice
Git and git workflow best practiceGit and git workflow best practice
Git and git workflow best practice
 
Git Intermediate Course
Git Intermediate CourseGit Intermediate Course
Git Intermediate Course
 
Git and GitHub
Git and GitHubGit and GitHub
Git and GitHub
 
Git Memento of basic commands
Git Memento of basic commandsGit Memento of basic commands
Git Memento of basic commands
 
Introduction to GIT
Introduction to GITIntroduction to GIT
Introduction to GIT
 
Git commands
Git commandsGit commands
Git commands
 
Hacktoberfest intro to Git and GitHub
Hacktoberfest intro to Git and GitHubHacktoberfest intro to Git and GitHub
Hacktoberfest intro to Git and GitHub
 
How to git easily in day to-day work
How to git easily in day to-day workHow to git easily in day to-day work
How to git easily in day to-day work
 
Git commands
Git commandsGit commands
Git commands
 
Git
GitGit
Git
 
Git 入门与实践
Git 入门与实践Git 入门与实践
Git 入门与实践
 
Git 入门 与 实践
Git 入门 与 实践Git 入门 与 实践
Git 入门 与 实践
 
The Fundamentals of Git
The Fundamentals of GitThe Fundamentals of Git
The Fundamentals of Git
 

Recently uploaded

Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
91mobiles
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
Kari Kakkonen
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
DianaGray10
 
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Inflectra
 
Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*
Frank van Harmelen
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
Thijs Feryn
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
Laura Byrne
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
Cheryl Hung
 
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Thierry Lestable
 
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Jeffrey Haguewood
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
DanBrown980551
 
Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyes
ThousandEyes
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
Alan Dix
 
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Product School
 
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
Product School
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
KatiaHIMEUR1
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
Prayukth K V
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
Safe Software
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
Paul Groth
 
Elevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object CalisthenicsElevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object Calisthenics
Dorra BARTAGUIZ
 

Recently uploaded (20)

Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
 
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
 
Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
 
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
 
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
 
Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyes
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
 
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...
 
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
 
Elevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object CalisthenicsElevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object Calisthenics
 

Git for beginners

  • 2. git ● Source code management software ● DVCS (Distributed Version Control System) ● hg - Similar tool ● CVS, Bazaar, SVN
  • 3. Installation ● Ubuntu sudo apt-get install git ● Windows
  • 4. Ubuntu and Windows ● Commands here can be executed in the respective OS as defined below ● Ubuntu ○ Can use their system terminal ● Windows ○ Select git bash in your Right-click context menu
  • 5. git Hosting Bitbucket Github Unlimited public and private repositories Unlimited Public repositories Cost based on number of users Cost based on number of repositories Supports git and hg Supports git only ● Codeplane, Githost, Assembla, Cloudforge, Gitorious ● Bitbucket Username - arulmurugan E-Mail - arulmurugan@example.com
  • 6. ssh-key Setup ● ssh-keygen #Command to generate public key ● Copy contents of id_rsa.pub
  • 9. Repo - User Management ● To manage who access your repository
  • 10. Git configuration Basic Configurations: ● git config --global user.name "second_user_name" ● git config --global user.email "second_user_email" ● git config --global push.default "matching" ● git config --global color.status auto ● git config --global color.branch auto ● git config --list Optional Configurations: ● git config --global branch.master.remote origin ● git config --global branch.master.merge refs/heads/master
  • 11. .gitignore ● Can be configured to ignore certain files and directories ● Git ignores empty directories by default
  • 12. My first repo ● cd ~/git/myproject/ #Open your project directory in terminal ● git init #Initiating a git repository ● git remote add origin git@bitbucket.org:arulmurugan/dummy.git #Adding remote repository URL ● git add . #Adding files to be committed ● git commit -m "Initial commit" #Committing the added files and changes ● git push origin master #Pushing the commits to remote repository
  • 14. git status ● Will show the list changed and new files which are yet to be committed
  • 15. git add & git commit ● git add . #To add all untracked files ● git add test2.html #To add specific files ● git commit -am "commit message" #To commit all changed files ● git commit -m "commit message" test1.html #To commit specific files
  • 16. git add & git commit (Contd...)
  • 17. Bitbucket - Source and Commits
  • 18. git pull ● To pull changes pushed by other users from remote repo to local repo
  • 19. Merge conflicts ● A merge conflicts occurs, if two people have modified the same content.
  • 21. Status and History ● git diff #Shows differences in uncommitted files / last commit ● git log #Shows history of commits in the current branch ● git log --oneline --abbrev-commit #Shows one line commit history with short commit id ● git log --graph --pretty --oneline --abbrev-commit #Shows the history as graph ● git diff-tree --name-only -r <commit_id> #Shows files changed in the commit ● git show <commit_id> #Shows changes in the commit
  • 22. History of file ● git log [filename] #Shows commits for the file ● git log -p [filename] #Shows commits for the file with changes ● git log --follow -p [filename] #Shows commits for the file including renames ● git blame [filename] #Shows author and commit per line of the file ● git blame -L 1,3 [filename] #Shows author and commit from line 2 to line 3 ● git commit --amend -m "More changes - now correct" #To amend changes to previous commit before pushing
  • 23. Remote repositories ● git remote #Show the existing remote repos ● git remote show origin #Show the details of remote repo origin ● git clone git@bitbucket.org:arulmurugan/dummy.git #To clone remote repository
  • 24. git stash ● Allows to save the current uncommitted changes and checkout the last committed revision. ● Allows you to pull in the latest changes without conflicts. ● Afterwards you can restore the stashed changes, which will apply the changes to the current version of the source code.
  • 25. git stash (Contd...) ● git stash save "stash message" #To save uncommited changes as stash ● git stash list #To view list of saved stashes #stash@{0}: On master: Title changed ● git stash apply stash@{0} #To apply the particular stash ● git stash drop stash@{0} #To drop particular stash ● git stash clear #To drop all saved stashes ● git stash pop #To apply most recent stash and delete it from list of stashes
  • 27. Reverting changes ● git clean - To remove newly added files ○ git clean -n #To see what would happen ○ git clean -f #To remove the files ● git checkout - To revert changed and deleted files ○ git checkout . #To revert all changed files ○ git checkout [filename] #To restore or revert the file ○ git checkout <commit_id> #To checkout a particular commit
  • 28. Reverting changes (Contd...) ● git reset [filename] #To remove a file added by git add before pushing ● git checkout HEAD -- [dir_name] #To recover an accidentally deleted directory in repo ● git revert <commit_id> #To revert a particular commit ● git reset --hard HEAD~1 #To delete last 1 commit ● git reset --hard <sha1-commit-id> #To delete upto a particular commit ● git push -f #Push with force to push commit deletions
  • 29. Reverting changes (Contd...) ● git reflog #Shows a history of the complete changes of your current branch based on the HEAD revision ● git reset --hard <commit_id> #To revert to a commit shown in git reflog
  • 30. Branches ● Branches are copies of the files from a certain commit and they can be changed independently from each other. ● The default branch is called master. ● Untracked files remain unchanged and are available in the new branch. This allows you to create a branch for unstaged and uncommitted changes at any point in time.
  • 31. Branches (Contd...) ● git branch #List available branches ● git branch -a #List available branches including remote branches ● git branch -r #List remote branches only ● git branch <branch_name> #To create new branch ● git checkout <branch_name> #To switch to a branch ● git checkout -b <branch_name> #To create a branch and switch to it
  • 32. Branches (Contd...) ● git checkout -b <branch_name> master~1 #Create a new branch based on master without last commit ● git branch -d <branch_name> #To delete a branch ● git push origin <branch_name> #To push branch to remote ● git push origin --delete <branch_name> #To delete a remote branch ● git checkout -b <branch_name> origin/<branch_name> #To create a tracking branch ● git merge <branch_name> #To merge specified branch with current branch
  • 33. Retrieving files ● git show [reference]:[filename] #To see contents of a file # [reference] can be a branch, tag, HEAD or commit ID ● git show [reference]:[filename] > [filename_copy] #To copy a file ● git log -- [filename] #To see commit history of a file, even if deleted
  • 34. Alias ● Allows you to setup your own git command ● git config --global alias.st 'git status' #Set command "st" for git status #Now git st can be used instead of git status ● git config --global alias.acm '!git add . -A && git commit' #Set command "acm" for git add . and git commit #Now you can use git acm "message" for commits #Not supported in windows*
  • 35. Submodules - Repos inside repos ● Allows you to include another Git repository into a Git repository ● git submodule add [URL to Git repo] #To add submodule to your repo ● After cloning a repo with submodules ○ git submodule init #Creates local configuration file for submodules ○ git submodule update #To clone submodules
  • 36. ● Rebase ● Patches ● Git server Missed Out: