SlideShare a Scribd company logo
1 of 13
Mastering Git
A Day with Git Workflow
Presented by-
Tahsin Abrar
Sr. Software Engineer
Blog: tahsinabrar.com
twitter: @TahsinAbrar
Git - What is it?
Git is a free and open source distributed version control system created by Linus
Torvalds in 2005 ( Who is also the creator of Linux kernel ).
It is designed to manage everything for small or very large projects with speed
and efficiency.
Majors organisations like Google, Facebook, Microsoft uses GIT daily.
But, It’s too complicated!
Most of the developer who doesn’t use git or
using git very little, they came up saying,
“Git is too complicated. It’s too hard to learn.
I don’t really understand it.”
Actually, Git is very easy to use and learn and
especially considering how powerful it is!
If you can have the basic understanding of git
flow, it’ll be a life saviour for YOU.
Typical Git Workflow
Pull the latest changes from remote
Write some codes
Add new files for staging
Commit the changes with readable commit message
Push the commit
Repeat.
Git Basic
git add file/path
To add all files: “ git add . ” OR “ git add -A ”
Commit: git commit -m “Your commit message”
View remote: git remote -v
To show the changes that you made after the last commit : git diff
To show all the previous commits in terminal : git log
Ref: http://tahsinabrar.github.io/2015/10/22/git-lifehacks/
Git Basic
To remove a file from git repo: “ git rm file/path ”
To move/rename a file: git mv current/file/path new/file/path”
To show all commits with reference log: git reflog
To show all the previous commits messages only in terminal: git log --oneline
Enhance the previous command: git log --oneline --graph
To show only few of the previous commits in terminal:
git log -<number>
i.e. git log -2 for last two commits
Git Clean/reset
To clean the current working directory from the last commit:
git clean -f
Remember, it’ll permanently remove your current changes.
You added the file to the stage, but not commited yet, Then:
git reset HEAD file/path
To reset the last commit that you didn’t push:
git reset --soft HEAD~1
To remove the changes of a file: git checkout file/path
Git Stash - THE Rescue
You’re in the middle of some changes but something comes up that you need to jump over
to, like a so-urgent-right-now bugfix, but don’t want to commit or lose your current edits. git
stash is there for you.
Run: git stash to make the working repository clean. And It will then leave you at the state
of the last commit.
Run: git stash pop or git stash apply to bring back the stashed code into the working
directory.
Run: git stash list to show the lists of stash items.
Git Branching
Create a new branch :
git branch newBranchName
Checkout to newly created branch:
git checkout newBranchName
Or, you can combine these two command with:
git checkout -b newBranchName
Delete a branch:
git branch -d branchName
Delete a branch forcefully:
git branch -D branchName
What should be gitignored ?
 If you’re using composer, then of course you should ignore /vendor directory.
 If you’re using bower, then you should also ignore :
 /bower_components directory.
 If you’re using npm, then ignore: /node_modules directory
 If you’re using sass as CSS Pre-processor, then ignore: /.sass-cache
directory
 And always ignore upload files path
Merge conflicts!
the number of planets are
<<<<<<< HEAD
nine // ---- This is your changes
=======
eight // ---- This is your friend’s changes
>>>>>>> myBranch
In myBranch, you wrote the word "nine," but your friend
wrote "eight." Git automatically adds conflict markers to
the affected areas. A conflict-marked area begins with
<<<<<<< and ends with >>>>>>>. These are also
known as the conflict markers. The two conflicting
blocks themselves are divided by a =======.
Using Git flow
It’s a great tool that will help if you’re working with a big team.
Ref: http://danielkummer.github.io/git-flow-cheatsheet/
Q & A
Thanks for your time.
Ask your valuable questions!

More Related Content

What's hot

What's hot (20)

Git in 10 minutes
Git in 10 minutesGit in 10 minutes
Git in 10 minutes
 
Git & Github
Git & GithubGit & Github
Git & Github
 
Git undo
Git undoGit undo
Git undo
 
Git tech talk
Git tech talkGit tech talk
Git tech talk
 
Getting Started on distributed version control with git
Getting Started on distributed version control with gitGetting Started on distributed version control with git
Getting Started on distributed version control with git
 
Introduction to Git
Introduction to GitIntroduction to Git
Introduction to Git
 
Git tutorial
Git tutorialGit tutorial
Git tutorial
 
Git from the trenches
Git from the trenchesGit from the trenches
Git from the trenches
 
Git and GitHub
Git and GitHubGit and GitHub
Git and GitHub
 
Git hub abduallah abu nada
Git hub   abduallah abu nadaGit hub   abduallah abu nada
Git hub abduallah abu nada
 
Git Basics - RubyFest 2009
Git Basics - RubyFest 2009Git Basics - RubyFest 2009
Git Basics - RubyFest 2009
 
#5 - Git - Contribuindo com um repositório remoto
#5 - Git - Contribuindo com um repositório remoto#5 - Git - Contribuindo com um repositório remoto
#5 - Git - Contribuindo com um repositório remoto
 
Introduction to Git
Introduction to GitIntroduction to Git
Introduction to Git
 
Git cheat sheet
Git cheat sheetGit cheat sheet
Git cheat sheet
 
Advance workshop on git
Advance workshop on gitAdvance workshop on git
Advance workshop on git
 
Introduction to Git (Greg Lonnon)
Introduction to Git (Greg Lonnon)Introduction to Git (Greg Lonnon)
Introduction to Git (Greg Lonnon)
 
Git & github
Git & githubGit & github
Git & github
 
Git basics
Git basicsGit basics
Git basics
 
Git,Travis,Gradle
Git,Travis,GradleGit,Travis,Gradle
Git,Travis,Gradle
 
#3 - Git - Branching e Merging
#3 - Git - Branching e Merging#3 - Git - Branching e Merging
#3 - Git - Branching e Merging
 

Similar to Mastering git - Workflow

Git for developers
Git for developersGit for developers
Git for developersHacen Dadda
 
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
 
Vincit Teatime 2015.2 - Otto Kekäläinen: Don't be a git
Vincit Teatime 2015.2 - Otto Kekäläinen: Don't be a gitVincit Teatime 2015.2 - Otto Kekäläinen: Don't be a git
Vincit Teatime 2015.2 - Otto Kekäläinen: Don't be a gitVincitOy
 
Introducing Git and git flow
Introducing Git and git flow Introducing Git and git flow
Introducing Git and git flow Sebin Benjamin
 
Git Memento of basic commands
Git Memento of basic commandsGit Memento of basic commands
Git Memento of basic commandsZakaria Bouazza
 
Hacktoberfest intro to Git and GitHub
Hacktoberfest intro to Git and GitHubHacktoberfest intro to Git and GitHub
Hacktoberfest intro to Git and GitHubDSC GVP
 
Introduction to git, a version control system
Introduction to git, a version control systemIntroduction to git, a version control system
Introduction to git, a version control systemKumaresh Chandra Baruri
 
Git with the flow
Git with the flowGit with the flow
Git with the flowDana White
 
Pro git - grasping it conceptually
Pro git - grasping it conceptuallyPro git - grasping it conceptually
Pro git - grasping it conceptuallyseungzzang Kim
 
Collaborative development with Git | Workshop
Collaborative development with Git | WorkshopCollaborative development with Git | Workshop
Collaborative development with Git | WorkshopAnuchit Chalothorn
 

Similar to Mastering git - Workflow (20)

git2.ppt
git2.pptgit2.ppt
git2.ppt
 
Git Init (Introduction to Git)
Git Init (Introduction to Git)Git Init (Introduction to Git)
Git Init (Introduction to Git)
 
Git for developers
Git for developersGit for developers
Git for developers
 
Git Commands Every Developer Should Know?
Git Commands Every Developer Should Know?Git Commands Every Developer Should Know?
Git Commands Every Developer Should Know?
 
git2.ppt
git2.pptgit2.ppt
git2.ppt
 
Git introduction
Git introductionGit introduction
Git introduction
 
1-Intro to VC & GIT PDF.pptx
1-Intro to VC & GIT PDF.pptx1-Intro to VC & GIT PDF.pptx
1-Intro to VC & GIT PDF.pptx
 
Git essentials
Git essentialsGit essentials
Git essentials
 
Vincit Teatime 2015.2 - Otto Kekäläinen: Don't be a git
Vincit Teatime 2015.2 - Otto Kekäläinen: Don't be a gitVincit Teatime 2015.2 - Otto Kekäläinen: Don't be a git
Vincit Teatime 2015.2 - Otto Kekäläinen: Don't be a git
 
Introducing Git and git flow
Introducing Git and git flow Introducing Git and git flow
Introducing Git and git flow
 
Git Memento of basic commands
Git Memento of basic commandsGit Memento of basic commands
Git Memento of basic commands
 
Git github
Git githubGit github
Git github
 
Hacktoberfest intro to Git and GitHub
Hacktoberfest intro to Git and GitHubHacktoberfest intro to Git and GitHub
Hacktoberfest intro to Git and GitHub
 
Git and github
Git and githubGit and github
Git and github
 
Introduction to git, a version control system
Introduction to git, a version control systemIntroduction to git, a version control system
Introduction to git, a version control system
 
16 Git
16 Git16 Git
16 Git
 
Git with the flow
Git with the flowGit with the flow
Git with the flow
 
Pro git - grasping it conceptually
Pro git - grasping it conceptuallyPro git - grasping it conceptually
Pro git - grasping it conceptually
 
Git and Github
Git and GithubGit and Github
Git and Github
 
Collaborative development with Git | Workshop
Collaborative development with Git | WorkshopCollaborative development with Git | Workshop
Collaborative development with Git | Workshop
 

Recently uploaded

Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Wonjun Hwang
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr LapshynFwdays
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
costume and set research powerpoint presentation
costume and set research powerpoint presentationcostume and set research powerpoint presentation
costume and set research powerpoint presentationphoebematthew05
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piececharlottematthew16
 

Recently uploaded (20)

DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
costume and set research powerpoint presentation
costume and set research powerpoint presentationcostume and set research powerpoint presentation
costume and set research powerpoint presentation
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piece
 
Hot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort Service
Hot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort ServiceHot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort Service
Hot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort Service
 

Mastering git - Workflow

  • 1. Mastering Git A Day with Git Workflow Presented by- Tahsin Abrar Sr. Software Engineer Blog: tahsinabrar.com twitter: @TahsinAbrar
  • 2. Git - What is it? Git is a free and open source distributed version control system created by Linus Torvalds in 2005 ( Who is also the creator of Linux kernel ). It is designed to manage everything for small or very large projects with speed and efficiency. Majors organisations like Google, Facebook, Microsoft uses GIT daily.
  • 3. But, It’s too complicated! Most of the developer who doesn’t use git or using git very little, they came up saying, “Git is too complicated. It’s too hard to learn. I don’t really understand it.” Actually, Git is very easy to use and learn and especially considering how powerful it is! If you can have the basic understanding of git flow, it’ll be a life saviour for YOU.
  • 4. Typical Git Workflow Pull the latest changes from remote Write some codes Add new files for staging Commit the changes with readable commit message Push the commit Repeat.
  • 5. Git Basic git add file/path To add all files: “ git add . ” OR “ git add -A ” Commit: git commit -m “Your commit message” View remote: git remote -v To show the changes that you made after the last commit : git diff To show all the previous commits in terminal : git log Ref: http://tahsinabrar.github.io/2015/10/22/git-lifehacks/
  • 6. Git Basic To remove a file from git repo: “ git rm file/path ” To move/rename a file: git mv current/file/path new/file/path” To show all commits with reference log: git reflog To show all the previous commits messages only in terminal: git log --oneline Enhance the previous command: git log --oneline --graph To show only few of the previous commits in terminal: git log -<number> i.e. git log -2 for last two commits
  • 7. Git Clean/reset To clean the current working directory from the last commit: git clean -f Remember, it’ll permanently remove your current changes. You added the file to the stage, but not commited yet, Then: git reset HEAD file/path To reset the last commit that you didn’t push: git reset --soft HEAD~1 To remove the changes of a file: git checkout file/path
  • 8. Git Stash - THE Rescue You’re in the middle of some changes but something comes up that you need to jump over to, like a so-urgent-right-now bugfix, but don’t want to commit or lose your current edits. git stash is there for you. Run: git stash to make the working repository clean. And It will then leave you at the state of the last commit. Run: git stash pop or git stash apply to bring back the stashed code into the working directory. Run: git stash list to show the lists of stash items.
  • 9. Git Branching Create a new branch : git branch newBranchName Checkout to newly created branch: git checkout newBranchName Or, you can combine these two command with: git checkout -b newBranchName Delete a branch: git branch -d branchName Delete a branch forcefully: git branch -D branchName
  • 10. What should be gitignored ?  If you’re using composer, then of course you should ignore /vendor directory.  If you’re using bower, then you should also ignore :  /bower_components directory.  If you’re using npm, then ignore: /node_modules directory  If you’re using sass as CSS Pre-processor, then ignore: /.sass-cache directory  And always ignore upload files path
  • 11. Merge conflicts! the number of planets are <<<<<<< HEAD nine // ---- This is your changes ======= eight // ---- This is your friend’s changes >>>>>>> myBranch In myBranch, you wrote the word "nine," but your friend wrote "eight." Git automatically adds conflict markers to the affected areas. A conflict-marked area begins with <<<<<<< and ends with >>>>>>>. These are also known as the conflict markers. The two conflicting blocks themselves are divided by a =======.
  • 12. Using Git flow It’s a great tool that will help if you’re working with a big team. Ref: http://danielkummer.github.io/git-flow-cheatsheet/
  • 13. Q & A Thanks for your time. Ask your valuable questions!