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

Git tech talk
Git tech talkGit tech talk
Git tech talk
razasayed
 

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

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

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 

Recently uploaded (20)

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 

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!