SlideShare uma empresa Scribd logo
1 de 51
Baixar para ler offline
Git
Agenda
 What is VCS?
 Where does Git comes from?
 Why is Git gaining popularity
 Why you should care
 Git for geeks
 Novice gitians
 GitLab – The git laboratory
What is VCS?
Mechanism to keep track your files and folders
Collaborate your work with fellow developers
Track of who did what and when
Backup
Types of VCS
CVCS (Subversion, CVS)
 Server is the only master
 All commits goes to server
 DVCS (Git, Mercurial)
 You too are a master
 Commits goes locally
 Work without even connecting to network
SERVERA
B
C
D
SERVER
A
C
B
D
A bit more on DVCS
 Your local machine is also like a server master repository
 No need of internet connectivity to use version control
 Committing changes will commit to your local repository
 No need to bang on server for history of changes or compares
 Insanely fast as most of things you do happens on local machine
 Effortless creation of branches
 Push code to remote (server) when you connect to network
 Fetch code from remote when you connect to network to make your code sync with fellow members
changes
Where does Git comes from?
Created by Linus Torvalds for managing Linux kernel back in 2005
Open source in nature (that’s obvious isn’t it?)
Why is Git gaining popularity
Designed for speed and efficiency
Insanely fast because of distribute local nature
Local nature makes creating branch process effortless
Much better that competing tools
Your best friend against
 Accidental deletes
 Remembering what is changed, when and WHY?
 Hard drive blow ups
The local nature of Git makes it possible to coalesce a series of changes (local commits) into a
single commit on the remote branch
Directorystructure
GIT Workflow
Obtain (a.k.a CLONE) a repository
 Either via git init, or git clone, or if you already have the repo, pull changes!
Make some edits
◦ Use your favorite text editor or source code IDE
◦ Most IDEs have Git integration, including NetBeans
◦ git tracks changes to binary files too: images, pdf, etc.
◦ Less useful though, than text-based files
Stage your changes
◦ using git add
Commit your work
◦ git commit -m "Always write clear commit messages!"
Push work to remote
 git push remotename localbranch:remotebranch
GIT Workflow
Git 101
Remote Repo
Working Directory
Index
Repository
"Staging"
"a copy of your project"
git add
git commit
git push
/ git pull
internet
your pc
"your clone of the remote repo"
your edits
git clone
Git for geeks – First Steps
 Set your Git username and email to your global config:
 git config --global user.name “Shinu Suresh"
 git config --global user.email “shinu_suresh01@infosys.com"*
 Setup SSH
 ssh-keygen
 Copy the public key to your remote repo server (GitLab – We will discuss this later)
 Creating a repository (If one not exist in remote)
 git init
 Cloning a remote repository
 git clone git@10.155.104.107:root/hybris-commerce-suite-5.4.1.git
 Inspecting your repo
 git status – Shows you added, modified, deleted files since your last commit
First Steps cont
 git log
 git log --pretty=oneline
 git log -1
Shows the commit logs in various formats
$ git add
 "This command updates the index using the current content found in the working tree, to prepare the
content staged for the next commit."
 In other words, stage your added, modified or deleted files for committing.
$ git commit -m "What did you change? Log messages matter.“
 "Stores the current contents of the index in a new commit along with a log message from the user describing the changes.“
 In other words, store the added, modified or deleted files you staged in your repository.
First Steps cont
 git push origin master
Pushing to the remote repository (from where you have cloned) branch (refspec) named master
REMEMBER:
 If you never commit, you have no history.
 If you never push, you have no offsite backup.
As a rule of thumb, commit every hour, push every day.
 There is no reason not to commit after every "logical stopping-point" and push when a good
section of work is complete, unit tests pass, etc.
After you push, your colleagues can pull changes down from the origin repository to their
local working repository.
First Steps cont
 git pull origin master (short way is git pull)
Pulling someone else changes from remote repo to your local repo
 "Incorporates changes from a remote repository into the current branch. In its default mode, git
pull is shorthand for git fetch followed by git merge FETCH_HEAD."
 In other words, retrieve changes made to the remote repo and merge them into your local repo,
updating your working copy to match.
First Steps cont
 git fetch origin master (Short way is git fetch)
 Only fetches changes from remote branch. Changes wont be merged to your working code base.
You have to do the merge manually
 Fetches the changes from remote branch (master) and put it inside origin/master
 git merge origin/master
 Will merge the changes fetched from remote repo to your local working directory
Workflow visualization
edits
git add git add git add
edits edits
git
commit
git
commit
git
commit
Repo
Work
Stage
Repo
Work
Stage
Repo
Work
Stage
Repo
--> time -->
Origin
git clone
git pull
Origin
git push
(git init)
internet
your pc
First Steps cont - Branching
 Why branches?
 Try out an idea - experiment
 Isolate work units - keep unfinished work separate
 Work on long-running topics - come back to things later
 Share your work in progress with others without altering the code in production or in
development (remote feature branches)
 Why is it so important?
 Branches are created in local and are pushed to remote
 Branch creation is effortless and faster
First Steps cont - Branching
 Why is it so important?
◦ Monday: You put all the client's code into a repo, clone it locally
◦ Tuesday: You create a branch to implement a new feature, making severalcommits
◦ Wednesday: You realize that it would be better to split out the feature into a couple different include files, so you create 2
new files and delete the old one. You commit your work.
◦ Thursday: The client contacts you frantically wanting a hot fix for an issue discovered on the version of the code on the live
site.
◦ What do you do now?
◦ You deleted their version of the file on Wednesday, right?
◦ No! You made a branch.
◦ Their original file is in the master branch still!
◦ If you hadn't branched, you would be either downloading their original file again, or reverting your changes back to the
version you had on Monday.
 Branches are created in local and are pushed to remote
 Branch creation is effortless and faster
First Steps cont - Branching
 git branch <feature name>
 Create a new branch instantaneously
 git branch –list
 List out all branches in local repository
 git checkout <branch name>
 Switch current working directory to the specified branch
 git merge <branch name>
 Merge changes in a local branch to your current branch which is checked out
 git merge origin/<branch name>
 Merge a remote branch to current branch which is checked out
Branching Workflow
git branch "Branch"
git checkout Branch
git checkout Master
git merge Branch
edits
git add git add git add
edits edits
git
commit
git
commit
git
commit
Master
Branch
Work
Stage
Branch
Work
Stage
Branch
Work
Stage
Master
Branch
--> time -->
Origin
git clone
git pull
Origin
git push
internet
your pc
Branching – Best Practices
◦ "master" is generally accepted to mean the main branch, that tracks what is deployed on the
client's site. This is the default; when creating a new repository it will have one branch named
master.
◦ "develop" or "development" is typically the name of a single branch that has newer code than
what is in master. Un-named bug fixes and improvements.
◦ "featureXYZ" or "issue123" - Branches named for specific features or specific issue tickets in a
3rd party bug tracker.
◦ You can have branches in your local repository that are not tracked, meaning they do not exist in
the remote repository. It's up to you.
◦ Even if you never make a feature branch, it's recommended to have at least one "development"
branch separate from "master"
QA
Development
Branches Production
Main Branches
Develop
Master
SupportingBranches
Feature Release Hotfix
Branch Naming
Feature – Anything except master, develop, release-*, hotfix-*
Eg:- Qas, Autosuggest, ScrollableProducts etc
Release – Release-*
Eg:- Release-v1.0.0 (Follow semver), Release-Woody, Release-CheckoutV2 etc
For more information on semver - http://semver.org/
Hotfix – Hotfix-*
Eg:- Hotfix-v1.0.0-PLPIssue, Hotfix-1.0-JIRA-1928 etc
Tag
Eg:- Tag-v1.0.0 (Following semver), Tag-Woody etc
Novice gitians
 Eclipse – Egit plugin
 Atlassian SourceTree
Tortoise GIT
Git Extensions
GitEye
Eclipse – Egit
First Steps - Configuration
 Add user
Add Email
Window  Preference
 Team
 Git
 Configuration
First Steps – SSH Keys
 Generate SSH Key
Window  Preference
 Network Connections
 SSH2
Save private
key
Copy this key
to gitlab
First Steps - Clone
Clone a repository
Perspective - Git
First Steps - Commit
Team
Commit
First Steps – History (log)
Team
Show in History – Commit history in History view
First Steps – SwitchingBranches
Team
Switch To
First Steps – Push to remote
Team
Remote  Push
First Steps – Pull from remote
Team
Pull
First Steps – Fetch from remote
Team
Fetch from Upstream
First Steps – Merge
Team
Merge
First Steps – Merge Conflicts
Team
Merge Tool
(Will show only file
Which have conflicts)
Git Staging View
GitLab
Opensource Git dashboard like GitHub
Activity Stream
File browser
Integrated wiki
Powerful Code review workflow
Issue Management
Code snippets
Web hooks (For CI integrations)
Workflow
Clone Project
Create branch with your feature
Write code, Commit changes
Push branch to GitLab
Review code on commit page
Create a merge request
Your team lead will review the code & merge it to the main branch
Git Lab – First Steps
Create a New User
Activate account
Git Lab – First Steps
Add SSH Key
Profile  SSH Key
First Steps
Add SSH Key to your account
Dashboard – ActivityStream
Activities on project
File Browser
Wiki
Merge Request & Code Review
 Merge requests from branches which
are cloned
 Eg:- Merge request from
development branch
 Discuss merge requests. Side by side
diff is available for review
 Suggest/Accept/Reject changes
 Once click merge is available from
frontend itself if branch is fast-
forward
 Emails on merge requests and up on
completions
Issue Management
 Release requirements can be an
issue
 Discussion threads
 Designs can be discussed over
comments
 Milestones can be added
Code Snippets
Jenkins Integration - CI
References
https://www.atlassian.com/git/tutorials/
https://try.github.io/levels/1/challenges/1
http://git-scm.com/docs/gittutorial
Eclipse Plugin tutorial
http://www.vogella.com/tutorials/EclipseGit/article.html

Mais conteúdo relacionado

Mais procurados

Mais procurados (20)

Git best practices workshop
Git best practices workshopGit best practices workshop
Git best practices workshop
 
Git basics to advance with diagrams
Git basics to advance with diagramsGit basics to advance with diagrams
Git basics to advance with diagrams
 
Git and git flow
Git and git flowGit and git flow
Git and git flow
 
Git & GitLab
Git & GitLabGit & GitLab
Git & GitLab
 
Introduction git
Introduction gitIntroduction git
Introduction git
 
Github
GithubGithub
Github
 
Git Tutorial For Beginners | What is Git and GitHub? | DevOps Tools | DevOps ...
Git Tutorial For Beginners | What is Git and GitHub? | DevOps Tools | DevOps ...Git Tutorial For Beginners | What is Git and GitHub? | DevOps Tools | DevOps ...
Git Tutorial For Beginners | What is Git and GitHub? | DevOps Tools | DevOps ...
 
Advanced Git Tutorial
Advanced Git TutorialAdvanced Git Tutorial
Advanced Git Tutorial
 
Git - An Introduction
Git - An IntroductionGit - An Introduction
Git - An Introduction
 
Learning git
Learning gitLearning git
Learning git
 
Git - Basic Crash Course
Git - Basic Crash CourseGit - Basic Crash Course
Git - Basic Crash Course
 
Git slides
Git slidesGit slides
Git slides
 
Starting with Git & GitHub
Starting with Git & GitHubStarting with Git & GitHub
Starting with Git & GitHub
 
Git Lab Introduction
Git Lab IntroductionGit Lab Introduction
Git Lab Introduction
 
Intro to Git and GitHub
Intro to Git and GitHubIntro to Git and GitHub
Intro to Git and GitHub
 
Introduction to Git
Introduction to GitIntroduction to Git
Introduction to Git
 
git and github
git and githubgit and github
git and github
 
Introduction to Git and Github
Introduction to Git and GithubIntroduction to Git and Github
Introduction to Git and Github
 
Git for beginners
Git for beginnersGit for beginners
Git for beginners
 
Git
GitGit
Git
 

Destaque

Merge version 2
Merge version 2Merge version 2
Merge version 2한울 채
 
Thinking routine - module 4
Thinking routine - module 4  Thinking routine - module 4
Thinking routine - module 4 Laura Martí
 
Eva rc module 2_activity_communicative skills
Eva rc module 2_activity_communicative skillsEva rc module 2_activity_communicative skills
Eva rc module 2_activity_communicative skillsEva R
 
Vitrine 12 .2015 Tupperware Essencial
Vitrine 12 .2015 Tupperware EssencialVitrine 12 .2015 Tupperware Essencial
Vitrine 12 .2015 Tupperware EssencialTUPPERWARE ESSENCIAL
 
Escultura del Renacimiento
Escultura del RenacimientoEscultura del Renacimiento
Escultura del RenacimientoMencar Car
 
TEMA 9. EL QUATTROCENTO. ARQUITECTURA Y PINTURA
TEMA 9. EL QUATTROCENTO. ARQUITECTURA Y PINTURATEMA 9. EL QUATTROCENTO. ARQUITECTURA Y PINTURA
TEMA 9. EL QUATTROCENTO. ARQUITECTURA Y PINTURA@evasociales
 
Vit 09 2016 Tupperware Tulipas
Vit 09 2016 Tupperware TulipasVit 09 2016 Tupperware Tulipas
Vit 09 2016 Tupperware TulipasCeluza Ferreira
 
Tema 3. los reinos cristianos de la reconquista
Tema 3. los reinos cristianos de la reconquistaTema 3. los reinos cristianos de la reconquista
Tema 3. los reinos cristianos de la reconquistacopybird
 

Destaque (16)

Merge version 2
Merge version 2Merge version 2
Merge version 2
 
US MARINE CERT
US MARINE CERTUS MARINE CERT
US MARINE CERT
 
Thinking routine - module 4
Thinking routine - module 4  Thinking routine - module 4
Thinking routine - module 4
 
Healthy food assessment
Healthy food assessmentHealthy food assessment
Healthy food assessment
 
Communicative skills
Communicative skillsCommunicative skills
Communicative skills
 
Eva rc module 2_activity_communicative skills
Eva rc module 2_activity_communicative skillsEva rc module 2_activity_communicative skills
Eva rc module 2_activity_communicative skills
 
Tema 2 AL ANDALUS
Tema 2 AL ANDALUSTema 2 AL ANDALUS
Tema 2 AL ANDALUS
 
VP 11/2015 Tupperware Essencial
VP 11/2015 Tupperware EssencialVP 11/2015 Tupperware Essencial
VP 11/2015 Tupperware Essencial
 
Vitrine 12 .2015 Tupperware Essencial
Vitrine 12 .2015 Tupperware EssencialVitrine 12 .2015 Tupperware Essencial
Vitrine 12 .2015 Tupperware Essencial
 
Vitrine 092016 TWESSENCIAL
Vitrine 092016 TWESSENCIALVitrine 092016 TWESSENCIAL
Vitrine 092016 TWESSENCIAL
 
VP 06.2016 Tupperware Essencial
VP 06.2016 Tupperware EssencialVP 06.2016 Tupperware Essencial
VP 06.2016 Tupperware Essencial
 
Escultura del Renacimiento
Escultura del RenacimientoEscultura del Renacimiento
Escultura del Renacimiento
 
TEMA 9. EL QUATTROCENTO. ARQUITECTURA Y PINTURA
TEMA 9. EL QUATTROCENTO. ARQUITECTURA Y PINTURATEMA 9. EL QUATTROCENTO. ARQUITECTURA Y PINTURA
TEMA 9. EL QUATTROCENTO. ARQUITECTURA Y PINTURA
 
Al-andalus
Al-andalusAl-andalus
Al-andalus
 
Vit 09 2016 Tupperware Tulipas
Vit 09 2016 Tupperware TulipasVit 09 2016 Tupperware Tulipas
Vit 09 2016 Tupperware Tulipas
 
Tema 3. los reinos cristianos de la reconquista
Tema 3. los reinos cristianos de la reconquistaTema 3. los reinos cristianos de la reconquista
Tema 3. los reinos cristianos de la reconquista
 

Semelhante a Git Beginner's Guide: Everything You Need to Know to Get Started with Git

Semelhante a Git Beginner's Guide: Everything You Need to Know to Get Started with Git (20)

Mini-training: Let’s Git It!
Mini-training: Let’s Git It!Mini-training: Let’s Git It!
Mini-training: Let’s Git It!
 
Subversion to Git Migration
Subversion to Git MigrationSubversion to Git Migration
Subversion to Git Migration
 
Git basics
Git basicsGit basics
Git basics
 
Git for developers
Git for developersGit for developers
Git for developers
 
Git usage (Basics and workflow)
Git usage (Basics and workflow)Git usage (Basics and workflow)
Git usage (Basics and workflow)
 
Embracing Distributed Version Control
Embracing Distributed Version ControlEmbracing Distributed Version Control
Embracing Distributed Version Control
 
Git cheat sheet__grey
Git cheat sheet__greyGit cheat sheet__grey
Git cheat sheet__grey
 
Git cheat sheet__white
Git cheat sheet__whiteGit cheat sheet__white
Git cheat sheet__white
 
Git cheat sheet_dark
Git cheat sheet_darkGit cheat sheet_dark
Git cheat sheet_dark
 
Beginner's Guide to Version Control with Git
Beginner's Guide to Version Control with GitBeginner's Guide to Version Control with Git
Beginner's Guide to Version Control with Git
 
Version Control ThinkVitamin
Version Control ThinkVitaminVersion Control ThinkVitamin
Version Control ThinkVitamin
 
Switching to Git
Switching to GitSwitching to Git
Switching to Git
 
.Git for WordPress Developers
.Git for WordPress Developers.Git for WordPress Developers
.Git for WordPress Developers
 
Git 101
Git 101Git 101
Git 101
 
3 Git
3 Git3 Git
3 Git
 
Git
GitGit
Git
 
Git more done
Git more doneGit more done
Git more done
 
Version control git day03
Version control   git day03Version control   git day03
Version control git day03
 
git Technologies
git Technologiesgit Technologies
git Technologies
 
Introduction to git & github
Introduction to git & githubIntroduction to git & github
Introduction to git & github
 

Mais de Shinu Suresh

Hybris 6.0.0 to 6.3.0 comparision
Hybris 6.0.0 to 6.3.0 comparisionHybris 6.0.0 to 6.3.0 comparision
Hybris 6.0.0 to 6.3.0 comparisionShinu Suresh
 
Continuous Integrations & Deployments
Continuous Integrations & DeploymentsContinuous Integrations & Deployments
Continuous Integrations & DeploymentsShinu Suresh
 
GitFlow, SourceTree and GitLab
GitFlow, SourceTree and GitLabGitFlow, SourceTree and GitLab
GitFlow, SourceTree and GitLabShinu Suresh
 
Websphere Commerce SEO
Websphere Commerce SEOWebsphere Commerce SEO
Websphere Commerce SEOShinu Suresh
 
Training material exceptions v1
Training material   exceptions v1Training material   exceptions v1
Training material exceptions v1Shinu Suresh
 
Training material sonar v1
Training material   sonar v1Training material   sonar v1
Training material sonar v1Shinu Suresh
 

Mais de Shinu Suresh (6)

Hybris 6.0.0 to 6.3.0 comparision
Hybris 6.0.0 to 6.3.0 comparisionHybris 6.0.0 to 6.3.0 comparision
Hybris 6.0.0 to 6.3.0 comparision
 
Continuous Integrations & Deployments
Continuous Integrations & DeploymentsContinuous Integrations & Deployments
Continuous Integrations & Deployments
 
GitFlow, SourceTree and GitLab
GitFlow, SourceTree and GitLabGitFlow, SourceTree and GitLab
GitFlow, SourceTree and GitLab
 
Websphere Commerce SEO
Websphere Commerce SEOWebsphere Commerce SEO
Websphere Commerce SEO
 
Training material exceptions v1
Training material   exceptions v1Training material   exceptions v1
Training material exceptions v1
 
Training material sonar v1
Training material   sonar v1Training material   sonar v1
Training material sonar v1
 

Último

VictoriaMetrics Q1 Meet Up '24 - Community & News Update
VictoriaMetrics Q1 Meet Up '24 - Community & News UpdateVictoriaMetrics Q1 Meet Up '24 - Community & News Update
VictoriaMetrics Q1 Meet Up '24 - Community & News UpdateVictoriaMetrics
 
Effectively Troubleshoot 9 Types of OutOfMemoryError
Effectively Troubleshoot 9 Types of OutOfMemoryErrorEffectively Troubleshoot 9 Types of OutOfMemoryError
Effectively Troubleshoot 9 Types of OutOfMemoryErrorTier1 app
 
Zer0con 2024 final share short version.pdf
Zer0con 2024 final share short version.pdfZer0con 2024 final share short version.pdf
Zer0con 2024 final share short version.pdfmaor17
 
Amazon Bedrock in Action - presentation of the Bedrock's capabilities
Amazon Bedrock in Action - presentation of the Bedrock's capabilitiesAmazon Bedrock in Action - presentation of the Bedrock's capabilities
Amazon Bedrock in Action - presentation of the Bedrock's capabilitiesKrzysztofKkol1
 
Leveraging AI for Mobile App Testing on Real Devices | Applitools + Kobiton
Leveraging AI for Mobile App Testing on Real Devices | Applitools + KobitonLeveraging AI for Mobile App Testing on Real Devices | Applitools + Kobiton
Leveraging AI for Mobile App Testing on Real Devices | Applitools + KobitonApplitools
 
Introduction to Firebase Workshop Slides
Introduction to Firebase Workshop SlidesIntroduction to Firebase Workshop Slides
Introduction to Firebase Workshop Slidesvaideheekore1
 
What’s New in VictoriaMetrics: Q1 2024 Updates
What’s New in VictoriaMetrics: Q1 2024 UpdatesWhat’s New in VictoriaMetrics: Q1 2024 Updates
What’s New in VictoriaMetrics: Q1 2024 UpdatesVictoriaMetrics
 
Enhancing Supply Chain Visibility with Cargo Cloud Solutions.pdf
Enhancing Supply Chain Visibility with Cargo Cloud Solutions.pdfEnhancing Supply Chain Visibility with Cargo Cloud Solutions.pdf
Enhancing Supply Chain Visibility with Cargo Cloud Solutions.pdfRTS corp
 
Tech Tuesday Slides - Introduction to Project Management with OnePlan's Work ...
Tech Tuesday Slides - Introduction to Project Management with OnePlan's Work ...Tech Tuesday Slides - Introduction to Project Management with OnePlan's Work ...
Tech Tuesday Slides - Introduction to Project Management with OnePlan's Work ...OnePlan Solutions
 
eSoftTools IMAP Backup Software and migration tools
eSoftTools IMAP Backup Software and migration toolseSoftTools IMAP Backup Software and migration tools
eSoftTools IMAP Backup Software and migration toolsosttopstonverter
 
Best Angular 17 Classroom & Online training - Naresh IT
Best Angular 17 Classroom & Online training - Naresh ITBest Angular 17 Classroom & Online training - Naresh IT
Best Angular 17 Classroom & Online training - Naresh ITmanoharjgpsolutions
 
SAM Training Session - How to use EXCEL ?
SAM Training Session - How to use EXCEL ?SAM Training Session - How to use EXCEL ?
SAM Training Session - How to use EXCEL ?Alexandre Beguel
 
The Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptx
The Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptxThe Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptx
The Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptxRTS corp
 
JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...
JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...
JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...Bert Jan Schrijver
 
Keeping your build tool updated in a multi repository world
Keeping your build tool updated in a multi repository worldKeeping your build tool updated in a multi repository world
Keeping your build tool updated in a multi repository worldRoberto Pérez Alcolea
 
The Ultimate Guide to Performance Testing in Low-Code, No-Code Environments (...
The Ultimate Guide to Performance Testing in Low-Code, No-Code Environments (...The Ultimate Guide to Performance Testing in Low-Code, No-Code Environments (...
The Ultimate Guide to Performance Testing in Low-Code, No-Code Environments (...kalichargn70th171
 
Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...
Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...
Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...OnePlan Solutions
 
[ CNCF Q1 2024 ] Intro to Continuous Profiling and Grafana Pyroscope.pdf
[ CNCF Q1 2024 ] Intro to Continuous Profiling and Grafana Pyroscope.pdf[ CNCF Q1 2024 ] Intro to Continuous Profiling and Grafana Pyroscope.pdf
[ CNCF Q1 2024 ] Intro to Continuous Profiling and Grafana Pyroscope.pdfSteve Caron
 
Understanding Plagiarism: Causes, Consequences and Prevention.pptx
Understanding Plagiarism: Causes, Consequences and Prevention.pptxUnderstanding Plagiarism: Causes, Consequences and Prevention.pptx
Understanding Plagiarism: Causes, Consequences and Prevention.pptxSasikiranMarri
 
Mastering Project Planning with Microsoft Project 2016.pptx
Mastering Project Planning with Microsoft Project 2016.pptxMastering Project Planning with Microsoft Project 2016.pptx
Mastering Project Planning with Microsoft Project 2016.pptxAS Design & AST.
 

Último (20)

VictoriaMetrics Q1 Meet Up '24 - Community & News Update
VictoriaMetrics Q1 Meet Up '24 - Community & News UpdateVictoriaMetrics Q1 Meet Up '24 - Community & News Update
VictoriaMetrics Q1 Meet Up '24 - Community & News Update
 
Effectively Troubleshoot 9 Types of OutOfMemoryError
Effectively Troubleshoot 9 Types of OutOfMemoryErrorEffectively Troubleshoot 9 Types of OutOfMemoryError
Effectively Troubleshoot 9 Types of OutOfMemoryError
 
Zer0con 2024 final share short version.pdf
Zer0con 2024 final share short version.pdfZer0con 2024 final share short version.pdf
Zer0con 2024 final share short version.pdf
 
Amazon Bedrock in Action - presentation of the Bedrock's capabilities
Amazon Bedrock in Action - presentation of the Bedrock's capabilitiesAmazon Bedrock in Action - presentation of the Bedrock's capabilities
Amazon Bedrock in Action - presentation of the Bedrock's capabilities
 
Leveraging AI for Mobile App Testing on Real Devices | Applitools + Kobiton
Leveraging AI for Mobile App Testing on Real Devices | Applitools + KobitonLeveraging AI for Mobile App Testing on Real Devices | Applitools + Kobiton
Leveraging AI for Mobile App Testing on Real Devices | Applitools + Kobiton
 
Introduction to Firebase Workshop Slides
Introduction to Firebase Workshop SlidesIntroduction to Firebase Workshop Slides
Introduction to Firebase Workshop Slides
 
What’s New in VictoriaMetrics: Q1 2024 Updates
What’s New in VictoriaMetrics: Q1 2024 UpdatesWhat’s New in VictoriaMetrics: Q1 2024 Updates
What’s New in VictoriaMetrics: Q1 2024 Updates
 
Enhancing Supply Chain Visibility with Cargo Cloud Solutions.pdf
Enhancing Supply Chain Visibility with Cargo Cloud Solutions.pdfEnhancing Supply Chain Visibility with Cargo Cloud Solutions.pdf
Enhancing Supply Chain Visibility with Cargo Cloud Solutions.pdf
 
Tech Tuesday Slides - Introduction to Project Management with OnePlan's Work ...
Tech Tuesday Slides - Introduction to Project Management with OnePlan's Work ...Tech Tuesday Slides - Introduction to Project Management with OnePlan's Work ...
Tech Tuesday Slides - Introduction to Project Management with OnePlan's Work ...
 
eSoftTools IMAP Backup Software and migration tools
eSoftTools IMAP Backup Software and migration toolseSoftTools IMAP Backup Software and migration tools
eSoftTools IMAP Backup Software and migration tools
 
Best Angular 17 Classroom & Online training - Naresh IT
Best Angular 17 Classroom & Online training - Naresh ITBest Angular 17 Classroom & Online training - Naresh IT
Best Angular 17 Classroom & Online training - Naresh IT
 
SAM Training Session - How to use EXCEL ?
SAM Training Session - How to use EXCEL ?SAM Training Session - How to use EXCEL ?
SAM Training Session - How to use EXCEL ?
 
The Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptx
The Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptxThe Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptx
The Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptx
 
JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...
JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...
JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...
 
Keeping your build tool updated in a multi repository world
Keeping your build tool updated in a multi repository worldKeeping your build tool updated in a multi repository world
Keeping your build tool updated in a multi repository world
 
The Ultimate Guide to Performance Testing in Low-Code, No-Code Environments (...
The Ultimate Guide to Performance Testing in Low-Code, No-Code Environments (...The Ultimate Guide to Performance Testing in Low-Code, No-Code Environments (...
The Ultimate Guide to Performance Testing in Low-Code, No-Code Environments (...
 
Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...
Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...
Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...
 
[ CNCF Q1 2024 ] Intro to Continuous Profiling and Grafana Pyroscope.pdf
[ CNCF Q1 2024 ] Intro to Continuous Profiling and Grafana Pyroscope.pdf[ CNCF Q1 2024 ] Intro to Continuous Profiling and Grafana Pyroscope.pdf
[ CNCF Q1 2024 ] Intro to Continuous Profiling and Grafana Pyroscope.pdf
 
Understanding Plagiarism: Causes, Consequences and Prevention.pptx
Understanding Plagiarism: Causes, Consequences and Prevention.pptxUnderstanding Plagiarism: Causes, Consequences and Prevention.pptx
Understanding Plagiarism: Causes, Consequences and Prevention.pptx
 
Mastering Project Planning with Microsoft Project 2016.pptx
Mastering Project Planning with Microsoft Project 2016.pptxMastering Project Planning with Microsoft Project 2016.pptx
Mastering Project Planning with Microsoft Project 2016.pptx
 

Git Beginner's Guide: Everything You Need to Know to Get Started with Git

  • 1. Git
  • 2. Agenda  What is VCS?  Where does Git comes from?  Why is Git gaining popularity  Why you should care  Git for geeks  Novice gitians  GitLab – The git laboratory
  • 3. What is VCS? Mechanism to keep track your files and folders Collaborate your work with fellow developers Track of who did what and when Backup
  • 4. Types of VCS CVCS (Subversion, CVS)  Server is the only master  All commits goes to server  DVCS (Git, Mercurial)  You too are a master  Commits goes locally  Work without even connecting to network SERVERA B C D SERVER A C B D
  • 5. A bit more on DVCS  Your local machine is also like a server master repository  No need of internet connectivity to use version control  Committing changes will commit to your local repository  No need to bang on server for history of changes or compares  Insanely fast as most of things you do happens on local machine  Effortless creation of branches  Push code to remote (server) when you connect to network  Fetch code from remote when you connect to network to make your code sync with fellow members changes
  • 6. Where does Git comes from? Created by Linus Torvalds for managing Linux kernel back in 2005 Open source in nature (that’s obvious isn’t it?)
  • 7. Why is Git gaining popularity Designed for speed and efficiency Insanely fast because of distribute local nature Local nature makes creating branch process effortless Much better that competing tools Your best friend against  Accidental deletes  Remembering what is changed, when and WHY?  Hard drive blow ups The local nature of Git makes it possible to coalesce a series of changes (local commits) into a single commit on the remote branch
  • 9. GIT Workflow Obtain (a.k.a CLONE) a repository  Either via git init, or git clone, or if you already have the repo, pull changes! Make some edits ◦ Use your favorite text editor or source code IDE ◦ Most IDEs have Git integration, including NetBeans ◦ git tracks changes to binary files too: images, pdf, etc. ◦ Less useful though, than text-based files Stage your changes ◦ using git add Commit your work ◦ git commit -m "Always write clear commit messages!" Push work to remote  git push remotename localbranch:remotebranch
  • 10. GIT Workflow Git 101 Remote Repo Working Directory Index Repository "Staging" "a copy of your project" git add git commit git push / git pull internet your pc "your clone of the remote repo" your edits git clone
  • 11. Git for geeks – First Steps  Set your Git username and email to your global config:  git config --global user.name “Shinu Suresh"  git config --global user.email “shinu_suresh01@infosys.com"*  Setup SSH  ssh-keygen  Copy the public key to your remote repo server (GitLab – We will discuss this later)  Creating a repository (If one not exist in remote)  git init  Cloning a remote repository  git clone git@10.155.104.107:root/hybris-commerce-suite-5.4.1.git  Inspecting your repo  git status – Shows you added, modified, deleted files since your last commit
  • 12. First Steps cont  git log  git log --pretty=oneline  git log -1 Shows the commit logs in various formats $ git add  "This command updates the index using the current content found in the working tree, to prepare the content staged for the next commit."  In other words, stage your added, modified or deleted files for committing. $ git commit -m "What did you change? Log messages matter.“  "Stores the current contents of the index in a new commit along with a log message from the user describing the changes.“  In other words, store the added, modified or deleted files you staged in your repository.
  • 13. First Steps cont  git push origin master Pushing to the remote repository (from where you have cloned) branch (refspec) named master REMEMBER:  If you never commit, you have no history.  If you never push, you have no offsite backup. As a rule of thumb, commit every hour, push every day.  There is no reason not to commit after every "logical stopping-point" and push when a good section of work is complete, unit tests pass, etc. After you push, your colleagues can pull changes down from the origin repository to their local working repository.
  • 14. First Steps cont  git pull origin master (short way is git pull) Pulling someone else changes from remote repo to your local repo  "Incorporates changes from a remote repository into the current branch. In its default mode, git pull is shorthand for git fetch followed by git merge FETCH_HEAD."  In other words, retrieve changes made to the remote repo and merge them into your local repo, updating your working copy to match.
  • 15. First Steps cont  git fetch origin master (Short way is git fetch)  Only fetches changes from remote branch. Changes wont be merged to your working code base. You have to do the merge manually  Fetches the changes from remote branch (master) and put it inside origin/master  git merge origin/master  Will merge the changes fetched from remote repo to your local working directory
  • 16. Workflow visualization edits git add git add git add edits edits git commit git commit git commit Repo Work Stage Repo Work Stage Repo Work Stage Repo --> time --> Origin git clone git pull Origin git push (git init) internet your pc
  • 17. First Steps cont - Branching  Why branches?  Try out an idea - experiment  Isolate work units - keep unfinished work separate  Work on long-running topics - come back to things later  Share your work in progress with others without altering the code in production or in development (remote feature branches)  Why is it so important?  Branches are created in local and are pushed to remote  Branch creation is effortless and faster
  • 18. First Steps cont - Branching  Why is it so important? ◦ Monday: You put all the client's code into a repo, clone it locally ◦ Tuesday: You create a branch to implement a new feature, making severalcommits ◦ Wednesday: You realize that it would be better to split out the feature into a couple different include files, so you create 2 new files and delete the old one. You commit your work. ◦ Thursday: The client contacts you frantically wanting a hot fix for an issue discovered on the version of the code on the live site. ◦ What do you do now? ◦ You deleted their version of the file on Wednesday, right? ◦ No! You made a branch. ◦ Their original file is in the master branch still! ◦ If you hadn't branched, you would be either downloading their original file again, or reverting your changes back to the version you had on Monday.  Branches are created in local and are pushed to remote  Branch creation is effortless and faster
  • 19. First Steps cont - Branching  git branch <feature name>  Create a new branch instantaneously  git branch –list  List out all branches in local repository  git checkout <branch name>  Switch current working directory to the specified branch  git merge <branch name>  Merge changes in a local branch to your current branch which is checked out  git merge origin/<branch name>  Merge a remote branch to current branch which is checked out
  • 20. Branching Workflow git branch "Branch" git checkout Branch git checkout Master git merge Branch edits git add git add git add edits edits git commit git commit git commit Master Branch Work Stage Branch Work Stage Branch Work Stage Master Branch --> time --> Origin git clone git pull Origin git push internet your pc
  • 21. Branching – Best Practices ◦ "master" is generally accepted to mean the main branch, that tracks what is deployed on the client's site. This is the default; when creating a new repository it will have one branch named master. ◦ "develop" or "development" is typically the name of a single branch that has newer code than what is in master. Un-named bug fixes and improvements. ◦ "featureXYZ" or "issue123" - Branches named for specific features or specific issue tickets in a 3rd party bug tracker. ◦ You can have branches in your local repository that are not tracked, meaning they do not exist in the remote repository. It's up to you. ◦ Even if you never make a feature branch, it's recommended to have at least one "development" branch separate from "master"
  • 25. Branch Naming Feature – Anything except master, develop, release-*, hotfix-* Eg:- Qas, Autosuggest, ScrollableProducts etc Release – Release-* Eg:- Release-v1.0.0 (Follow semver), Release-Woody, Release-CheckoutV2 etc For more information on semver - http://semver.org/ Hotfix – Hotfix-* Eg:- Hotfix-v1.0.0-PLPIssue, Hotfix-1.0-JIRA-1928 etc Tag Eg:- Tag-v1.0.0 (Following semver), Tag-Woody etc
  • 26. Novice gitians  Eclipse – Egit plugin  Atlassian SourceTree Tortoise GIT Git Extensions GitEye
  • 27. Eclipse – Egit First Steps - Configuration  Add user Add Email Window  Preference  Team  Git  Configuration
  • 28. First Steps – SSH Keys  Generate SSH Key Window  Preference  Network Connections  SSH2 Save private key Copy this key to gitlab
  • 29. First Steps - Clone Clone a repository Perspective - Git
  • 30. First Steps - Commit Team Commit
  • 31. First Steps – History (log) Team Show in History – Commit history in History view
  • 32. First Steps – SwitchingBranches Team Switch To
  • 33. First Steps – Push to remote Team Remote  Push
  • 34. First Steps – Pull from remote Team Pull
  • 35. First Steps – Fetch from remote Team Fetch from Upstream
  • 36. First Steps – Merge Team Merge
  • 37. First Steps – Merge Conflicts Team Merge Tool (Will show only file Which have conflicts)
  • 39. GitLab Opensource Git dashboard like GitHub Activity Stream File browser Integrated wiki Powerful Code review workflow Issue Management Code snippets Web hooks (For CI integrations)
  • 40. Workflow Clone Project Create branch with your feature Write code, Commit changes Push branch to GitLab Review code on commit page Create a merge request Your team lead will review the code & merge it to the main branch
  • 41. Git Lab – First Steps Create a New User Activate account
  • 42. Git Lab – First Steps Add SSH Key Profile  SSH Key
  • 43. First Steps Add SSH Key to your account
  • 46. Wiki
  • 47. Merge Request & Code Review  Merge requests from branches which are cloned  Eg:- Merge request from development branch  Discuss merge requests. Side by side diff is available for review  Suggest/Accept/Reject changes  Once click merge is available from frontend itself if branch is fast- forward  Emails on merge requests and up on completions
  • 48. Issue Management  Release requirements can be an issue  Discussion threads  Designs can be discussed over comments  Milestones can be added