SlideShare a Scribd company logo
GETTING STARTED WITH GIT
• git is a vcs version control system for managing code.
• git is a centralized distributed vcs
• github requires subscription for private repos, on bitbucket we can have a free private repo.
pawaan.v[at]gmail.com
HANDS ON USING LINUX DISTRO OR WSL ON WINDOWS
• If you are windows 10 wsl (windows subsystem for linux) a full blown Ubuntu distoro can be installed
ref : https://docs.microsoft.com/en-us/windows/wsl/install-win10
• On linux install git from apt for deb based distros and yum/dnf for rpm based distros
#apt-get install git -y
#yum install git -y
#git --version
• Check wsl home directory from command
#echo $HOME
#echo $USER
• Navigate to windows user directory using the command
#cd /mnt/c/Users/username
#ls
•
pawaan.v[at]gmail.c
GENERATING AND ADDING SSH KEYS TO GITHUB OR BITBUCKET
• ssh-keygen –t rsa -b 4096 -C email@example.com
• eval $(ssh-agent -s)
• ssh-add ~/.ssh/id_rsa
• Verify the permissions of id_rsa to be 600
• Once the key is generated add it to
git at: https://github.com/settings/keys
bitbucket at: https://bitbucket.org/account/user/<user>/ssh-keys
• Testing ssh authentication to git and bitbucket
ssh -T git@github.com
ssh -T git@bitbucket.org
• Configuring global options
#git config --global --edit
CLONING INTO AN EXISTING GIT PROJECT
• Git clone is used to clone an existing project from git, pull can be http based and ssh based.
-If a pull is done from http method , when the user wants to push the code every time the
authentication needs to be entered.
-If code is pulled using ssh , user need not provide credentials every time while pushing the code
taking into account that ssh keys are already added to the account
• #git clone https://github.com/pawaanv/cipher-setup
#cd cipher-setup
#echo “adding Version file”
#echo “version 1.0 > version”
#git commit -m “added version name”
#git push
• Create a empty git project
#mkdir njord
#cd njord
#git init
#ls
ALIASES
• Shorthand commands for git instead of typing long commands
#git config --global alias.co checkout
#git config --global alias.br branch
#git config --global alias.ci commit
#git config --global alias.st status
#git config --global alias.cl clone
#git conifg --global alias.ph push
#git config --global alias.pl pull
#git pl --help
• While storing files on git we don’t want to put password files and confidential info in public repos,
avoiding larger files
#echo “passwords” > .gitignore
• Checking the difference between the commits
#git diff commit1 commit2
GIT CUSTOMIZATION
• #git status
#git config -l
#git config -e
#git config --global user.name “Pawan kumar”
#git config --global user.email pawaan.v@gmail.com
#git conig --global color.ui auto
#git status
refer : https://git-scm.com/book/en/v2/Customizing-Git-Git-Configuration
• Adding files to the empty git repo
#touch httpd.sh
#git add httpd.sh
#git add -A
#echo > “#!/bin/bash”
#git commit –m “apache”
#git push -v
#git status
if you are single user working on the git with multiple devices and want to get the latest changes to be
pulled then add below code to .bashrc
#echo >> “git -C ~$USER/cipher-setup/ pull” >> $HOME/.bashrc
REMOTE GIT REPOS, TAGS
• Check the remote git repo status from command
#git remote –v
#git remote add pb https://bitbucket.org/cipheronic/cipher-setup
#git fetch pb
#git remote show origin
#git remote rename pb cipher
#git remote
#git remote remove cipher
#git remote
• Git repos can be tagged in history
there are two types of tags “Annotated tags & lightweight” tags
Annotated tags store full git objects and databases
Lightweight tags are like branches they just pointers to the git branch location
#git tag -a v.1 -m “my version v.1”
#git show v.1
git push does not push the tags it has to be done explicitly
#git push origin v.1
To push all the tags
#git push origin --tags
GIT BRANCHING
• By default user will be working in master branch ( default which is created when git init is run)
user check check the current branch they are working under using the command
#git branch
• New branch can be added with the command
#git branch test
#git branch -v
• User can switch to the new branch with the command
#git brahch test
#git checkout test
or
#git checkout -b test
#git branch –d test
#git branch --merged
#git branch --no-merged
• Logs
#git log
#git log --oneline –decorate
#git log --pretty=oneline
#git
pawaan.v[at]gmail.c

More Related Content

What's hot

Golang workshop
Golang workshopGolang workshop
Golang workshop
Victor S. Recio
 
Git Gyan
Git GyanGit Gyan
Git Gyan
Ravishankar S R
 
MongoDB World 2019 Builder's Fest - Ready, Git set ... Go!
MongoDB World 2019 Builder's Fest - Ready, Git set ... Go!MongoDB World 2019 Builder's Fest - Ready, Git set ... Go!
MongoDB World 2019 Builder's Fest - Ready, Git set ... Go!
Stennie Steneker
 
How to install git on ubuntu
How to install git on ubuntuHow to install git on ubuntu
How to install git on ubuntu
baran19901990
 
GIT - DUG Antwerp
GIT - DUG AntwerpGIT - DUG Antwerp
GIT - DUG Antwerp
Krimson
 
Git for a newbie
Git for a newbieGit for a newbie
Git for a newbie
Anuj Sharma
 
Getting started & Hosting your website on GitHub
Getting started & Hosting your website on GitHubGetting started & Hosting your website on GitHub
Getting started & Hosting your website on GitHubKartik Kannapur
 
Presentacion git
Presentacion gitPresentacion git
Presentacion git
Ignacio Martín
 
Introduction to Gitlab | Gitlab 101 | Training Session
Introduction to Gitlab | Gitlab 101 | Training SessionIntroduction to Gitlab | Gitlab 101 | Training Session
Introduction to Gitlab | Gitlab 101 | Training Session
Anwarul Islam
 
Introduction to GIT
Introduction to GITIntroduction to GIT
Introduction to GIT
Tata Taufik Nugraha
 
Luis atencio on_git
Luis atencio on_gitLuis atencio on_git
Luis atencio on_git
Luis Atencio
 
Git workshop
Git workshopGit workshop
Git workshop
Mateusz Galazyn
 
Gorush: A push notification server written in Go
Gorush: A push notification server written in GoGorush: A push notification server written in Go
Gorush: A push notification server written in Go
Bo-Yi Wu
 
Fall18 Git presentation
Fall18 Git presentationFall18 Git presentation
Fall18 Git presentation
JustinTirrell1
 
Git advanced
Git advancedGit advanced
Git advanced
Peter Vandenabeele
 
Introduction to GitHub Actions
Introduction to GitHub ActionsIntroduction to GitHub Actions
Introduction to GitHub Actions
Bo-Yi Wu
 
Git Version Control System
Git Version Control SystemGit Version Control System
Git Version Control System
KMS Technology
 
Git 101
Git 101Git 101
Git Tutorial I
Git Tutorial IGit Tutorial I
Git Tutorial I
Jim Yeh
 

What's hot (20)

Golang workshop
Golang workshopGolang workshop
Golang workshop
 
Git Gyan
Git GyanGit Gyan
Git Gyan
 
MongoDB World 2019 Builder's Fest - Ready, Git set ... Go!
MongoDB World 2019 Builder's Fest - Ready, Git set ... Go!MongoDB World 2019 Builder's Fest - Ready, Git set ... Go!
MongoDB World 2019 Builder's Fest - Ready, Git set ... Go!
 
How to install git on ubuntu
How to install git on ubuntuHow to install git on ubuntu
How to install git on ubuntu
 
GIT - DUG Antwerp
GIT - DUG AntwerpGIT - DUG Antwerp
GIT - DUG Antwerp
 
Git for a newbie
Git for a newbieGit for a newbie
Git for a newbie
 
Getting started & Hosting your website on GitHub
Getting started & Hosting your website on GitHubGetting started & Hosting your website on GitHub
Getting started & Hosting your website on GitHub
 
Presentacion git
Presentacion gitPresentacion git
Presentacion git
 
Introduction to Gitlab | Gitlab 101 | Training Session
Introduction to Gitlab | Gitlab 101 | Training SessionIntroduction to Gitlab | Gitlab 101 | Training Session
Introduction to Gitlab | Gitlab 101 | Training Session
 
Introduction to GIT
Introduction to GITIntroduction to GIT
Introduction to GIT
 
Luis atencio on_git
Luis atencio on_gitLuis atencio on_git
Luis atencio on_git
 
Git workshop
Git workshopGit workshop
Git workshop
 
Gorush: A push notification server written in Go
Gorush: A push notification server written in GoGorush: A push notification server written in Go
Gorush: A push notification server written in Go
 
Fall18 Git presentation
Fall18 Git presentationFall18 Git presentation
Fall18 Git presentation
 
Git advanced
Git advancedGit advanced
Git advanced
 
Introduction to GitHub Actions
Introduction to GitHub ActionsIntroduction to GitHub Actions
Introduction to GitHub Actions
 
Git cli
Git cliGit cli
Git cli
 
Git Version Control System
Git Version Control SystemGit Version Control System
Git Version Control System
 
Git 101
Git 101Git 101
Git 101
 
Git Tutorial I
Git Tutorial IGit Tutorial I
Git Tutorial I
 

Similar to Getting started with git

Github - Git Training Slides: Foundations
Github - Git Training Slides: FoundationsGithub - Git Training Slides: Foundations
Github - Git Training Slides: Foundations
Lee Hanxue
 
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
 
Git Heaven with Wakanda
Git Heaven with WakandaGit Heaven with Wakanda
Git Heaven with Wakanda
Juergen Fesslmeier
 
Git and Github workshop GDSC MLRITM
Git and Github  workshop GDSC MLRITMGit and Github  workshop GDSC MLRITM
Git and Github workshop GDSC MLRITM
gdsc13
 
Git hub
Git hubGit hub
Git hub
Nitin Goel
 
Git (Sistema Distribuido de Control de Versiones)
Git (Sistema Distribuido de Control de Versiones)Git (Sistema Distribuido de Control de Versiones)
Git (Sistema Distribuido de Control de Versiones)
TAWS
 
Introducción a Git
Introducción a GitIntroducción a Git
Introducción a Git
Juan Antonio
 
Git: Why And How to
Git: Why And How toGit: Why And How to
Git: Why And How to
lanhuonga3
 
Git Commands Every Developer Should Know?
Git Commands Every Developer Should Know?Git Commands Every Developer Should Know?
Git Commands Every Developer Should Know?
9 series
 
Github By Nyros Developer
Github By Nyros DeveloperGithub By Nyros Developer
Github By Nyros Developer
Nyros Technologies
 
Git 入门与实践
Git 入门与实践Git 入门与实践
Git 入门与实践Terry Wang
 
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 101615Brian K. Vagnini
 
Git
GitGit
Git 入门 与 实践
Git 入门 与 实践Git 入门 与 实践
Git 入门 与 实践Terry Wang
 
Source Code Management with Git
Source Code Management with GitSource Code Management with Git
Source Code Management with GitThings Lab
 
Advanced Git Tutorial
Advanced Git TutorialAdvanced Git Tutorial
Advanced Git Tutorial
Sage Sharp
 
簡單介紹git
簡單介紹git簡單介紹git
簡單介紹git
Grace Chien
 
Git basics
Git basicsGit basics
Git basics
Amit Sawhney
 

Similar to Getting started with git (20)

Introduction to Git and Github
Introduction to Git and GithubIntroduction to Git and Github
Introduction to Git and Github
 
Github - Git Training Slides: Foundations
Github - Git Training Slides: FoundationsGithub - Git Training Slides: Foundations
Github - Git Training Slides: Foundations
 
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
 
Git Heaven with Wakanda
Git Heaven with WakandaGit Heaven with Wakanda
Git Heaven with Wakanda
 
Git and Github workshop GDSC MLRITM
Git and Github  workshop GDSC MLRITMGit and Github  workshop GDSC MLRITM
Git and Github workshop GDSC MLRITM
 
Git hub
Git hubGit hub
Git hub
 
Git (Sistema Distribuido de Control de Versiones)
Git (Sistema Distribuido de Control de Versiones)Git (Sistema Distribuido de Control de Versiones)
Git (Sistema Distribuido de Control de Versiones)
 
Introducción a Git
Introducción a GitIntroducción a Git
Introducción a Git
 
Git: Why And How to
Git: Why And How toGit: Why And How to
Git: Why And How to
 
Git Commands Every Developer Should Know?
Git Commands Every Developer Should Know?Git Commands Every Developer Should Know?
Git Commands Every Developer Should Know?
 
Github By Nyros Developer
Github By Nyros DeveloperGithub By Nyros Developer
Github By Nyros Developer
 
Git
GitGit
Git
 
Git 入门与实践
Git 入门与实践Git 入门与实践
Git 入门与实践
 
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
 
Git
GitGit
Git
 
Git 入门 与 实践
Git 入门 与 实践Git 入门 与 实践
Git 入门 与 实践
 
Source Code Management with Git
Source Code Management with GitSource Code Management with Git
Source Code Management with Git
 
Advanced Git Tutorial
Advanced Git TutorialAdvanced Git Tutorial
Advanced Git Tutorial
 
簡單介紹git
簡單介紹git簡單介紹git
簡單介紹git
 
Git basics
Git basicsGit basics
Git basics
 

Recently uploaded

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 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
DianaGray10
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
Ana-Maria Mihalceanu
 
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
Product School
 
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
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
Guy Korland
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Albert Hoitingh
 
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
 
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
 
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
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
OnBoard
 
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
Product School
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
ControlCase
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
BookNet Canada
 
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
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Product School
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance
 
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
 
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
 

Recently uploaded (20)

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 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
 
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
 
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
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
 
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...
 
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
 
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
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
 
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
 
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
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
 
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 ...
 
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
 

Getting started with git

  • 1. GETTING STARTED WITH GIT • git is a vcs version control system for managing code. • git is a centralized distributed vcs • github requires subscription for private repos, on bitbucket we can have a free private repo. pawaan.v[at]gmail.com
  • 2. HANDS ON USING LINUX DISTRO OR WSL ON WINDOWS • If you are windows 10 wsl (windows subsystem for linux) a full blown Ubuntu distoro can be installed ref : https://docs.microsoft.com/en-us/windows/wsl/install-win10 • On linux install git from apt for deb based distros and yum/dnf for rpm based distros #apt-get install git -y #yum install git -y #git --version • Check wsl home directory from command #echo $HOME #echo $USER • Navigate to windows user directory using the command #cd /mnt/c/Users/username #ls • pawaan.v[at]gmail.c
  • 3. GENERATING AND ADDING SSH KEYS TO GITHUB OR BITBUCKET • ssh-keygen –t rsa -b 4096 -C email@example.com • eval $(ssh-agent -s) • ssh-add ~/.ssh/id_rsa • Verify the permissions of id_rsa to be 600 • Once the key is generated add it to git at: https://github.com/settings/keys bitbucket at: https://bitbucket.org/account/user/<user>/ssh-keys • Testing ssh authentication to git and bitbucket ssh -T git@github.com ssh -T git@bitbucket.org • Configuring global options #git config --global --edit
  • 4. CLONING INTO AN EXISTING GIT PROJECT • Git clone is used to clone an existing project from git, pull can be http based and ssh based. -If a pull is done from http method , when the user wants to push the code every time the authentication needs to be entered. -If code is pulled using ssh , user need not provide credentials every time while pushing the code taking into account that ssh keys are already added to the account • #git clone https://github.com/pawaanv/cipher-setup #cd cipher-setup #echo “adding Version file” #echo “version 1.0 > version” #git commit -m “added version name” #git push • Create a empty git project #mkdir njord #cd njord #git init #ls
  • 5. ALIASES • Shorthand commands for git instead of typing long commands #git config --global alias.co checkout #git config --global alias.br branch #git config --global alias.ci commit #git config --global alias.st status #git config --global alias.cl clone #git conifg --global alias.ph push #git config --global alias.pl pull #git pl --help • While storing files on git we don’t want to put password files and confidential info in public repos, avoiding larger files #echo “passwords” > .gitignore • Checking the difference between the commits #git diff commit1 commit2
  • 6. GIT CUSTOMIZATION • #git status #git config -l #git config -e #git config --global user.name “Pawan kumar” #git config --global user.email pawaan.v@gmail.com #git conig --global color.ui auto #git status refer : https://git-scm.com/book/en/v2/Customizing-Git-Git-Configuration • Adding files to the empty git repo #touch httpd.sh #git add httpd.sh #git add -A #echo > “#!/bin/bash” #git commit –m “apache” #git push -v #git status if you are single user working on the git with multiple devices and want to get the latest changes to be pulled then add below code to .bashrc #echo >> “git -C ~$USER/cipher-setup/ pull” >> $HOME/.bashrc
  • 7. REMOTE GIT REPOS, TAGS • Check the remote git repo status from command #git remote –v #git remote add pb https://bitbucket.org/cipheronic/cipher-setup #git fetch pb #git remote show origin #git remote rename pb cipher #git remote #git remote remove cipher #git remote • Git repos can be tagged in history there are two types of tags “Annotated tags & lightweight” tags Annotated tags store full git objects and databases Lightweight tags are like branches they just pointers to the git branch location #git tag -a v.1 -m “my version v.1” #git show v.1 git push does not push the tags it has to be done explicitly #git push origin v.1 To push all the tags #git push origin --tags
  • 8. GIT BRANCHING • By default user will be working in master branch ( default which is created when git init is run) user check check the current branch they are working under using the command #git branch • New branch can be added with the command #git branch test #git branch -v • User can switch to the new branch with the command #git brahch test #git checkout test or #git checkout -b test #git branch –d test #git branch --merged #git branch --no-merged • Logs #git log #git log --oneline –decorate #git log --pretty=oneline #git pawaan.v[at]gmail.c