SlideShare a Scribd company logo
1 of 36
Git 
Presenter: Hirantha Weerarathna
Road map 
• What is Git? 
• Version Control Systems 
• Few Useful Git Commands 
• Git Workflows 
• Git Hooks 
• Github
What is Git 
● Distributed Version Control System 
● Developed by Linus Torvalds for linux kernel developments 
● Free Software
Version Control Systems 
Distributed version control
git init 
-create a local repo 
git clone /path 
-clone a repo 
Few Useful Commands 
git add [filename] 
-add file into ‘staging area’ 
git commit -m “your_message” 
-commit 
git status 
-show the status of files
Few Useful Commands 
git remote add –u [remote_repo_name] [remote_repo_url] 
git push [remote_repo_name] [branch_name] 
-push into remote repo 
git pull [remote_repo_name] [branch_name] 
-pull from remote repo 
git branch [branch_name] 
-create a branch called ‘branch_name’ 
git checkout [branch_name] 
-checkout a branch 
git merge [branch_name] 
-merge a branch
Git Workflows 
● Centralized workflow 
● Feature Branch workflow 
● GitFlow workflow 
● Forking workflow
Centralized workflow 
Someone initialize the central repository 
ssh user@host git init --bare /path/to/repo.git 
“Central repositories should always be bare repositories (they shouldn’t have a working 
directory)”
Centralized workflow 
Everybody clones the central repository 
git clone ssh://user@host/path/to/repo.git
Centralized workflow 
John works on his feature 
git add <some-files> 
git commit <some-files>
Centralized workflow 
Marry works on her feature 
git add <some-files> 
git commit <some-files>
Centralized workflow 
John publishes his feature 
git push origin master
Centralized workflow 
Mary tries to publish her feature 
git push origin master 
error: failed to push some refs to '/path/to/repo.git' 
hint: Updates were rejected because the tip of your current branch is behind 
hint: its remote counterpart. Merge the remote changes (e.g. 'git pull') 
hint: before pushing again. hint: See the 'Note about fast-forwards' in 'git push --help' for details.
Centralized workflow 
Mary rebases on top of John’s commit(s) 
git pull --rebase origin master 
“--rebase option tells Git to move all of Mary’s commits to the tip of the master branch after 
synchronising it with the changes from the central repository”
Mary resolves a merge conflict 
CONFLICT (content): Merge conflict in <some-file> 
git add <some-file> 
git rebase –continue 
git rebase --abort 
Centralized workflow
Centralized workflow 
Mary successfully publishes her feature 
git push origin master
Feature Branch workflow 
•Feature Branch Workflow still uses a central repository 
•All feature development should take place in a dedicated branch 
instead of the master branch. 
•makes it possible to leverage pull requests
Feature Branch workflow 
Mary begins a new feature 
git checkout -b marys-feature master 
Building up her feature with as many commits 
git status 
git add <some-file> 
git commit 
Mary finishes her feature 
git push origin marys-feature
Feature Branch workflow 
She files the pull request in her Git GUI asking to merge marys-feature into 
master 
Bill receives the pull request 
Bill takes a look at marys-feature. 
He decides he wants to make a few changes before integrating it into the official 
project
Feature Branch workflow 
He and Mary have some back-and-forth via the pull request. 
Mary edits, stages, commits, and pushes updates to the central repository. 
All her activity shows up in the pull request, and Bill can still make comments 
along the way.
Feature Branch workflow 
Mary publishes her feature. 
git checkout master 
git pull 
git pull origin marys-feature 
git push
Gitflow Workflow 
•Gitflow Workflow defines a strict branching model designed around the 
project release. 
•Provides a robust framework for managing larger projects. 
•Doesn’t add any new concepts or commands beyond what’s required for the 
Feature Branch Workflow. 
•In addition to feature branches, it uses individual branches for preparing, 
maintaining, and recording releases. 
•The Gitflow Workflow still uses a central repository as the communication hub 
for all developers.
Gitflow Workflow 
Historical Branches 
Mater Branch - stores the official release history 
Develop Branch - serves as an integration branch for features.
Gitflow Workflow 
Feature Branches 
•Each new feature should reside in its own branch 
•Feature branches use develop as their parent branch not the master. 
•When a feature is complete, it gets merged back into develop. 
•Features should never interact directly with master.
Gitflow Workflow 
Release Branches 
•Once develop has acquired enough features for a release, you fork a release branch off of 
develop. 
•Only bug fixes, documentation generation, and other release-oriented tasks should go in 
this branch. 
•Once it's ready to ship, the release gets merged into master and tagged with a version 
number. 
•Then should be merged back into develop.
Gitflow Workflow 
Maintenance Branches 
•Maintenance or “hotfix” branches are used to quickly patch production releases. 
•This is the only branch that should fork directly off of master. 
•As soon as the fix is complete, it should be merged into both master and develop
Git Hooks 
•Git has a way to fire off custom scripts when certain important actions occur. 
•There are two groups of these hooks: 
client-side: triggered by operations such as committing and merging 
server-side: run on network operations such as receiving pushed commits. 
•Hooks are local. Not copied in a clone operation 
•The built-in scripts are mostly shell and PERL scripts, but you can use any 
scripting language
Git Branching and Merging 
• SVN branches are only used to capture the occasional large-scale 
development effort 
• Git branches are an integral part of your everyday workflow. 
• Git branches is much more lightweight than SVN’s model 
• Every bug fix or feature should start in a new branch despite the size of the 
work 
• SVN branch house a copy of the trunk but it doesn't store any information 
regarding when and what things got merged back in.
Github 
GitHub provides a web-based graphical interface, desktop as well as mobile 
integration and several collaboration features such as wikis, task management, 
and bug tracking and pull requests
How Pull Request Works 
1. A developer creates the feature in a dedicated branch in their local 
repo. 
2. The developer pushes the branch to a public Github/Bitbucket 
repository. 
3. The developer files a pull request via Github. 
4. The rest of the team reviews the code, discusses it, and alters it. 
5. The project maintainer merges the feature into the official 
repository and closes the pull request.
Gists 
• Adds version control for code snippets, mini projects 
• Each “gist” is its own Git repository 
• Can be pushed and pulled using Git
References 
• https://github.com 
• https://www.atlassian.com/git 
• http://git-scm.com
Staging Area 
● aka. index 
● holding area 
● allow you to split a large commit 
● You can also commit specific lines of files if you really wanted 
● use ‘git gui’ 
● used for temporarily stashing your changes 
Go back
Rebase 
•Put your commit after all others 
•Transferring each local commit to the updated master branch one at a time. 
This means that you catch merge conflicts on a commit-by-commit 
•should not do if someone else clone/fork from your repo 
Go back
Pull Request 
•Pull requests are a mechanism for a developer to notify team members that 
they have completed a feature. 
•Give other developers the opportunity to sign off on a feature before it gets 
integrated into the official project 
•If you get stuck in the middle of a feature, you can open a pull request asking 
for suggestions from your colleagues. 
Go back

More Related Content

What's hot

Introduction to git administration
Introduction to git administrationIntroduction to git administration
Introduction to git administrationShawn Doyle
 
Git branching strategies
Git branching strategiesGit branching strategies
Git branching strategiesjstack
 
Git and GitHub workflows
Git and GitHub workflowsGit and GitHub workflows
Git and GitHub workflowsArthur Shvetsov
 
Introduction to github slideshare
Introduction to github slideshareIntroduction to github slideshare
Introduction to github slideshareRakesh Sukumar
 
An introduction to Git and GitFlow
An introduction to Git and GitFlowAn introduction to Git and GitFlow
An introduction to Git and GitFlowMark Everard
 
Version control git day02
Version control   git day02Version control   git day02
Version control git day02Gourav Varma
 
Git tutorial git branches 20131206-Bryan
Git tutorial   git branches 20131206-BryanGit tutorial   git branches 20131206-Bryan
Git tutorial git branches 20131206-BryanLearningTech
 
Git Series. Episode 2. Merge, Upstream Commands and Tags
Git Series. Episode 2. Merge, Upstream Commands and TagsGit Series. Episode 2. Merge, Upstream Commands and Tags
Git Series. Episode 2. Merge, Upstream Commands and TagsMikhail Melnik
 
Git censored.key
Git censored.keyGit censored.key
Git censored.keymkramer2
 
Git Ready! Workflows
Git Ready! WorkflowsGit Ready! Workflows
Git Ready! WorkflowsAtlassian
 
A successful Git branching model
A successful Git branching model A successful Git branching model
A successful Git branching model abodeltae
 
Version control git day03(amarnath dada)
Version control   git day03(amarnath dada)Version control   git day03(amarnath dada)
Version control git day03(amarnath dada)Gourav Varma
 
Version control git day01
Version control   git day01Version control   git day01
Version control git day01Gourav Varma
 
Using Git and BitBucket
Using Git and BitBucketUsing Git and BitBucket
Using Git and BitBucketMedhat Dawoud
 
Version control git day02
Version control   git day02Version control   git day02
Version control git day02Gourav Varma
 
Code Review with Git and Gerrit - Devoxx 2011 - Tools in Action - 2011-11-14
Code Review with Git and Gerrit - Devoxx 2011 - Tools in Action - 2011-11-14Code Review with Git and Gerrit - Devoxx 2011 - Tools in Action - 2011-11-14
Code Review with Git and Gerrit - Devoxx 2011 - Tools in Action - 2011-11-14msohn
 
Software Versioning with Bitbucket and Eclipse
Software Versioning with Bitbucket and EclipseSoftware Versioning with Bitbucket and Eclipse
Software Versioning with Bitbucket and EclipseHüseyin Ergin
 

What's hot (20)

Introduction to git administration
Introduction to git administrationIntroduction to git administration
Introduction to git administration
 
Git branching strategies
Git branching strategiesGit branching strategies
Git branching strategies
 
Git and GitHub workflows
Git and GitHub workflowsGit and GitHub workflows
Git and GitHub workflows
 
Introduction to github slideshare
Introduction to github slideshareIntroduction to github slideshare
Introduction to github slideshare
 
An introduction to Git and GitFlow
An introduction to Git and GitFlowAn introduction to Git and GitFlow
An introduction to Git and GitFlow
 
Git workflows
Git workflowsGit workflows
Git workflows
 
Version control git day02
Version control   git day02Version control   git day02
Version control git day02
 
Git tutorial git branches 20131206-Bryan
Git tutorial   git branches 20131206-BryanGit tutorial   git branches 20131206-Bryan
Git tutorial git branches 20131206-Bryan
 
Git Series. Episode 2. Merge, Upstream Commands and Tags
Git Series. Episode 2. Merge, Upstream Commands and TagsGit Series. Episode 2. Merge, Upstream Commands and Tags
Git Series. Episode 2. Merge, Upstream Commands and Tags
 
Real-World Git
Real-World GitReal-World Git
Real-World Git
 
Git censored.key
Git censored.keyGit censored.key
Git censored.key
 
Git Ready! Workflows
Git Ready! WorkflowsGit Ready! Workflows
Git Ready! Workflows
 
A successful Git branching model
A successful Git branching model A successful Git branching model
A successful Git branching model
 
Version control git day03(amarnath dada)
Version control   git day03(amarnath dada)Version control   git day03(amarnath dada)
Version control git day03(amarnath dada)
 
Git presentation
Git presentationGit presentation
Git presentation
 
Version control git day01
Version control   git day01Version control   git day01
Version control git day01
 
Using Git and BitBucket
Using Git and BitBucketUsing Git and BitBucket
Using Git and BitBucket
 
Version control git day02
Version control   git day02Version control   git day02
Version control git day02
 
Code Review with Git and Gerrit - Devoxx 2011 - Tools in Action - 2011-11-14
Code Review with Git and Gerrit - Devoxx 2011 - Tools in Action - 2011-11-14Code Review with Git and Gerrit - Devoxx 2011 - Tools in Action - 2011-11-14
Code Review with Git and Gerrit - Devoxx 2011 - Tools in Action - 2011-11-14
 
Software Versioning with Bitbucket and Eclipse
Software Versioning with Bitbucket and EclipseSoftware Versioning with Bitbucket and Eclipse
Software Versioning with Bitbucket and Eclipse
 

Similar to Git Workflow and Commands Guide

Similar to Git Workflow and Commands Guide (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!
 
Switching to Git
Switching to GitSwitching to Git
Switching to Git
 
Working with Git
Working with GitWorking with Git
Working with Git
 
Version control git day03
Version control   git day03Version control   git day03
Version control git day03
 
Lets git to it
Lets git to itLets git to it
Lets git to it
 
Introducing Git and git flow
Introducing Git and git flow Introducing Git and git flow
Introducing Git and git flow
 
Git
GitGit
Git
 
Git basic
Git basicGit basic
Git basic
 
Introduction to git
Introduction to gitIntroduction to git
Introduction to git
 
Git Workflow
Git WorkflowGit Workflow
Git Workflow
 
Git more done
Git more doneGit more done
Git more done
 
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
 
Introduction to git hub
Introduction to git hubIntroduction to git hub
Introduction to git hub
 
GIT.pptx
GIT.pptxGIT.pptx
GIT.pptx
 
Git tips and tricks
Git   tips and tricksGit   tips and tricks
Git tips and tricks
 
Git and GitHub (1).pptx
Git and GitHub (1).pptxGit and GitHub (1).pptx
Git and GitHub (1).pptx
 
Introduction into Git
Introduction into GitIntroduction into Git
Introduction into Git
 
Git and Github slides.pdf
Git and Github slides.pdfGit and Github slides.pdf
Git and Github slides.pdf
 
Git and Github workshop ppt slide by slide
Git and Github workshop ppt slide by slideGit and Github workshop ppt slide by slide
Git and Github workshop ppt slide by slide
 
GIT In Detail
GIT In DetailGIT In Detail
GIT In Detail
 

Recently uploaded

What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWave PLM
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEOrtus Solutions, Corp
 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptkotipi9215
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...ICS
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideChristina Lin
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...stazi3110
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)OPEN KNOWLEDGE GmbH
 
Engage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyEngage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyFrank van der Linden
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...soniya singh
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxbodapatigopi8531
 
Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...aditisharan08
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityNeo4j
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio, Inc.
 
The Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdfThe Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdfPower Karaoke
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...kellynguyen01
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comFatema Valibhai
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software DevelopersVinodh Ram
 
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝soniya singh
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackVICTOR MAESTRE RAMIREZ
 

Recently uploaded (20)

What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need It
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.ppt
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)
 
Engage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyEngage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The Ugly
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
 
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptx
 
Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered Sustainability
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
 
The Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdfThe Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdf
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software Developers
 
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStack
 

Git Workflow and Commands Guide

  • 2. Road map • What is Git? • Version Control Systems • Few Useful Git Commands • Git Workflows • Git Hooks • Github
  • 3. What is Git ● Distributed Version Control System ● Developed by Linus Torvalds for linux kernel developments ● Free Software
  • 4. Version Control Systems Distributed version control
  • 5. git init -create a local repo git clone /path -clone a repo Few Useful Commands git add [filename] -add file into ‘staging area’ git commit -m “your_message” -commit git status -show the status of files
  • 6. Few Useful Commands git remote add –u [remote_repo_name] [remote_repo_url] git push [remote_repo_name] [branch_name] -push into remote repo git pull [remote_repo_name] [branch_name] -pull from remote repo git branch [branch_name] -create a branch called ‘branch_name’ git checkout [branch_name] -checkout a branch git merge [branch_name] -merge a branch
  • 7. Git Workflows ● Centralized workflow ● Feature Branch workflow ● GitFlow workflow ● Forking workflow
  • 8. Centralized workflow Someone initialize the central repository ssh user@host git init --bare /path/to/repo.git “Central repositories should always be bare repositories (they shouldn’t have a working directory)”
  • 9. Centralized workflow Everybody clones the central repository git clone ssh://user@host/path/to/repo.git
  • 10. Centralized workflow John works on his feature git add <some-files> git commit <some-files>
  • 11. Centralized workflow Marry works on her feature git add <some-files> git commit <some-files>
  • 12. Centralized workflow John publishes his feature git push origin master
  • 13. Centralized workflow Mary tries to publish her feature git push origin master error: failed to push some refs to '/path/to/repo.git' hint: Updates were rejected because the tip of your current branch is behind hint: its remote counterpart. Merge the remote changes (e.g. 'git pull') hint: before pushing again. hint: See the 'Note about fast-forwards' in 'git push --help' for details.
  • 14. Centralized workflow Mary rebases on top of John’s commit(s) git pull --rebase origin master “--rebase option tells Git to move all of Mary’s commits to the tip of the master branch after synchronising it with the changes from the central repository”
  • 15. Mary resolves a merge conflict CONFLICT (content): Merge conflict in <some-file> git add <some-file> git rebase –continue git rebase --abort Centralized workflow
  • 16. Centralized workflow Mary successfully publishes her feature git push origin master
  • 17. Feature Branch workflow •Feature Branch Workflow still uses a central repository •All feature development should take place in a dedicated branch instead of the master branch. •makes it possible to leverage pull requests
  • 18. Feature Branch workflow Mary begins a new feature git checkout -b marys-feature master Building up her feature with as many commits git status git add <some-file> git commit Mary finishes her feature git push origin marys-feature
  • 19. Feature Branch workflow She files the pull request in her Git GUI asking to merge marys-feature into master Bill receives the pull request Bill takes a look at marys-feature. He decides he wants to make a few changes before integrating it into the official project
  • 20. Feature Branch workflow He and Mary have some back-and-forth via the pull request. Mary edits, stages, commits, and pushes updates to the central repository. All her activity shows up in the pull request, and Bill can still make comments along the way.
  • 21. Feature Branch workflow Mary publishes her feature. git checkout master git pull git pull origin marys-feature git push
  • 22. Gitflow Workflow •Gitflow Workflow defines a strict branching model designed around the project release. •Provides a robust framework for managing larger projects. •Doesn’t add any new concepts or commands beyond what’s required for the Feature Branch Workflow. •In addition to feature branches, it uses individual branches for preparing, maintaining, and recording releases. •The Gitflow Workflow still uses a central repository as the communication hub for all developers.
  • 23. Gitflow Workflow Historical Branches Mater Branch - stores the official release history Develop Branch - serves as an integration branch for features.
  • 24. Gitflow Workflow Feature Branches •Each new feature should reside in its own branch •Feature branches use develop as their parent branch not the master. •When a feature is complete, it gets merged back into develop. •Features should never interact directly with master.
  • 25. Gitflow Workflow Release Branches •Once develop has acquired enough features for a release, you fork a release branch off of develop. •Only bug fixes, documentation generation, and other release-oriented tasks should go in this branch. •Once it's ready to ship, the release gets merged into master and tagged with a version number. •Then should be merged back into develop.
  • 26. Gitflow Workflow Maintenance Branches •Maintenance or “hotfix” branches are used to quickly patch production releases. •This is the only branch that should fork directly off of master. •As soon as the fix is complete, it should be merged into both master and develop
  • 27. Git Hooks •Git has a way to fire off custom scripts when certain important actions occur. •There are two groups of these hooks: client-side: triggered by operations such as committing and merging server-side: run on network operations such as receiving pushed commits. •Hooks are local. Not copied in a clone operation •The built-in scripts are mostly shell and PERL scripts, but you can use any scripting language
  • 28. Git Branching and Merging • SVN branches are only used to capture the occasional large-scale development effort • Git branches are an integral part of your everyday workflow. • Git branches is much more lightweight than SVN’s model • Every bug fix or feature should start in a new branch despite the size of the work • SVN branch house a copy of the trunk but it doesn't store any information regarding when and what things got merged back in.
  • 29. Github GitHub provides a web-based graphical interface, desktop as well as mobile integration and several collaboration features such as wikis, task management, and bug tracking and pull requests
  • 30. How Pull Request Works 1. A developer creates the feature in a dedicated branch in their local repo. 2. The developer pushes the branch to a public Github/Bitbucket repository. 3. The developer files a pull request via Github. 4. The rest of the team reviews the code, discusses it, and alters it. 5. The project maintainer merges the feature into the official repository and closes the pull request.
  • 31. Gists • Adds version control for code snippets, mini projects • Each “gist” is its own Git repository • Can be pushed and pulled using Git
  • 32. References • https://github.com • https://www.atlassian.com/git • http://git-scm.com
  • 33.
  • 34. Staging Area ● aka. index ● holding area ● allow you to split a large commit ● You can also commit specific lines of files if you really wanted ● use ‘git gui’ ● used for temporarily stashing your changes Go back
  • 35. Rebase •Put your commit after all others •Transferring each local commit to the updated master branch one at a time. This means that you catch merge conflicts on a commit-by-commit •should not do if someone else clone/fork from your repo Go back
  • 36. Pull Request •Pull requests are a mechanism for a developer to notify team members that they have completed a feature. •Give other developers the opportunity to sign off on a feature before it gets integrated into the official project •If you get stuck in the middle of a feature, you can open a pull request asking for suggestions from your colleagues. Go back

Editor's Notes

  1. Result in a merge commit. But, if you’re partial to a linear history, it’s possible to rebase the feature onto the tip of master before executing the merge, resulting in a fast-forward merge.
  2. It's also convenient to tag all commits in the master branch with a version number.
  3. Having a dedicated line of development for bug fixes lets your team address issues without interrupting the rest of the workflow or waiting for the next release cycle.
  4. .sample extension prevents them from executing by default. To “install” a hook, all you have to do is remove the .sample extension. The pre-commit hook is run first, before you even type in a commit message. It’s used to inspect the snapshot that’s about to be committed