SlideShare a Scribd company logo
GIT ADVANCED
Version control System
WHAT IS GIT & IT’S ADVANTAGES
➤ Git is a version control system that
helps you manage and save your
changes over time. Developed in
2005 by Linus Torvalds, the
famous creator of the Linux
operating system kernel.
Advantages:
➤ Complete long term change
history for all file.
➤ Being able to trace each change
made.
➤ Allow multiple team members to
collaborate on same code.
➤ Provide backup copy.
`
➤ Git basics (Git setup and server integration).
➤ Git branches and merging.
➤ Undoing things (Manipulating git history
snapshot).
➤ Making open source contribution.
➤ Various Git workflows & git hooks.
➤ Useful Git tools.
GIT BASIC (GIT SETUP AND SERVER INTEGRATION)
— Create a git repo.
— Cloning a git repo.
— Setting git config
creating commands alias
git config user.name
git config user.name "Sahil Gupta"
git config --global alias.ci commit
git config credential.helper store
— add changes to git repo.
— checking git status
— committing your changes.
— Pushing your changes to remote.
— Create new branches
— checkout a new branch
— Doing above 2 steps in one.
GIT BASIC (GIT SETUP AND SERVER INTEGRATION) CONTINUED…
— Fetching a remote changes.
— Delete branches.
— Stash changes
— getting back the stash changes into any branch
— checking git history
GIT LOG:
— git log , git log -n, git log -p, git log <file>, git log —graph,
git log --graph --decorate --oneline, git log --author="Sahil”,
git shortlog, git log --after="2014-7-1" --before="2014-7-4”,
git log --author="John”, git log -- foo.py bar.py, git log master..feature
Git Stash:
— git stash, git stash save <msg>, git stash pop [stash@{2}], git stash apply, git stash
list, git stash show, git stash show -p, git stash drop [stash@{2}], git stash clear
GIT BASIC (GIT SETUP AND SERVER INTEGRATION) CONTINUED…
GITIGNORE:
— .gitignore [Use glowing pattern]
**/logs
.log
/debug.log
logs/
— adding comment # ignore all logs
— Adding multiple .gitignore
— Ignoring a previous committed files
edit .gitignore && git rm --cached debug.log
— *.log !debug.log. Ignore pattern with an exception
— collection of useful gitignore templates
https://github.com/github/gitignore
GIT BRANCHES AND MERGING
— Create a new branch.
— Switch between the branches.
— Delete unwanted branches.
— How to move changes between branches.
— rebase & merging
— Merging branches.
(i). Fast forward merging.
(ii). 3 way merging.
— what is —no-ff in merging
— Merging specific commit
git cherry-pick <SHA ID>
UNDOING THINGS(VIEWING AND MANIPULATING HISTORY)
— Viewing git history (git log).
— Go back to some previous commit state.
— How we run into “Detached Head” state.
— Remove untracked changes.
— Remove stagged changes.
— Remove committed changes.
— Remove commits from Remote branch.
Associated Commands:
checkout, clean,revert,reset
MAKING OPEN SOURCE CONTRIBUTION
— Fork a repo.
— Clone local copy of Repo.
— Make changes and push it to forked copy.
— Create pull request.
— Finally wait for approver to accept/reject your pull request.
GIT WORFLOWS & GIT HOOKS
Major different git workflow:
— Centralised workflow.
— Feature branches workflow.
— Gitflow workflow.
— Forking Workflow.
Git Hooks:
— scripts can be be written in any scripting languages. Most
popular language used are shell, Python and perl.
— First script line defines the interpreter
#!/bin/sh : shell
#!/usr/bin/env python : Pathon
— Git hooks are local in scope. You can share it by adding it
outside .git, template directory or creating sum links.
Git hooks continued….
— Local Hooks
• pre-commit
• prepare-commit-msg
• commit-msg
• post-commit
• post-checkout
• pre-rebase
— Server side Hooks:
• pre-receive
• update
• post-receive
GIT GUI TOOLS
Built in tools:
— gitk& git-gui
Third Party Tools:
— SourceTree
— Meld
— Git kraken
Reference : https://git-scm.com/downloads/guis/
GIT TIPS AND DISCUSSION
— Difference between Fetch and Pull.
— Difference between merge and rebase
— Difference between git log and git status
— Difference between git reset —hard vs git reset —soft vs git
reset —mixed
— Force push and issues in it.
— How to combine multiple commit, git reset —soft <sha-1 hash>
— Rewriting history/How to change last commit with new
changes.
Advanted git

More Related Content

What's hot

Fall18 Git presentation
Fall18 Git presentationFall18 Git presentation
Fall18 Git presentation
JustinTirrell1
 
Git Introduction
Git IntroductionGit Introduction
Git Introduction
Gareth Hall
 
Gitting out of trouble
Gitting out of troubleGitting out of trouble
Gitting out of trouble
Jon Senchyna
 
Git: basic to advanced
Git: basic to advancedGit: basic to advanced
Git: basic to advanced
Yodalee
 
Git and fundamentals
Git and fundamentalsGit and fundamentals
Git and fundamentals
Naincy Gupta
 
Git Gyan
Git GyanGit Gyan
Git Gyan
Ravishankar S R
 
Git 101
Git 101Git 101
Git 101
jayrparro
 
Git
GitGit
Git tutorial
Git tutorialGit tutorial
Git tutorial
Pham Quy (Jack)
 
Getting started with git
Getting started with gitGetting started with git
Getting started with git
Pawan Kumar.v
 
Git Tricks
Git TricksGit Tricks
Git Tricks
Ivelina Dimova
 
Git.odp 0
Git.odp 0Git.odp 0
Git.odp 0
Mannu Malhotra
 
Git for beginners
Git for beginnersGit for beginners
Git for beginners
Arulmurugan Rajaraman
 
Introduction to Git
Introduction to GitIntroduction to Git
Introduction to Git
Colin Su
 
Basic git
Basic gitBasic git
Basic git
Casper Chen
 
Git tutorial
Git tutorialGit tutorial
Git tutorial
mobaires
 
Git 101
Git 101Git 101
Git 101
Kate Semizhon
 
Git tech talk
Git tech talkGit tech talk
Git tech talk
razasayed
 
Version Control System - Git
Version Control System - GitVersion Control System - Git
Version Control System - Git
Carlo Bernaschina
 
Git presentation
Git presentationGit presentation
Git presentation
Vikas Yaligar
 

What's hot (20)

Fall18 Git presentation
Fall18 Git presentationFall18 Git presentation
Fall18 Git presentation
 
Git Introduction
Git IntroductionGit Introduction
Git Introduction
 
Gitting out of trouble
Gitting out of troubleGitting out of trouble
Gitting out of trouble
 
Git: basic to advanced
Git: basic to advancedGit: basic to advanced
Git: basic to advanced
 
Git and fundamentals
Git and fundamentalsGit and fundamentals
Git and fundamentals
 
Git Gyan
Git GyanGit Gyan
Git Gyan
 
Git 101
Git 101Git 101
Git 101
 
Git
GitGit
Git
 
Git tutorial
Git tutorialGit tutorial
Git tutorial
 
Getting started with git
Getting started with gitGetting started with git
Getting started with git
 
Git Tricks
Git TricksGit Tricks
Git Tricks
 
Git.odp 0
Git.odp 0Git.odp 0
Git.odp 0
 
Git for beginners
Git for beginnersGit for beginners
Git for beginners
 
Introduction to Git
Introduction to GitIntroduction to Git
Introduction to Git
 
Basic git
Basic gitBasic git
Basic git
 
Git tutorial
Git tutorialGit tutorial
Git tutorial
 
Git 101
Git 101Git 101
Git 101
 
Git tech talk
Git tech talkGit tech talk
Git tech talk
 
Version Control System - Git
Version Control System - GitVersion Control System - Git
Version Control System - Git
 
Git presentation
Git presentationGit presentation
Git presentation
 

Similar to Advanted git

Git training v10
Git training v10Git training v10
Git training v10
Skander Hamza
 
Advanced Git Tutorial
Advanced Git TutorialAdvanced Git Tutorial
Advanced Git Tutorial
Sage Sharp
 
Git and github
Git and githubGit and github
Git and github
Teodora Ahkozidou
 
Git and Github
Git and GithubGit and Github
Git and Github
Teodora Ahkozidou
 
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
 
Git hub
Git hubGit hub
Git hub
Nitin Goel
 
Github By Nyros Developer
Github By Nyros DeveloperGithub By Nyros Developer
Github By Nyros Developer
Nyros Technologies
 
Git github
Git githubGit github
Git github
Anurag Deb
 
Learn Git - For Beginners and Intermediate levels
Learn Git - For Beginners and Intermediate levelsLearn Git - For Beginners and Intermediate levels
Learn Git - For Beginners and Intermediate levels
Gorav Singal
 
The Fundamentals of Git
The Fundamentals of GitThe Fundamentals of Git
The Fundamentals of Git
DivineOmega
 
Git: Why And How to
Git: Why And How toGit: Why And How to
Git: Why And How to
lanhuonga3
 
Mini-training: Let’s Git It!
Mini-training: Let’s Git It!Mini-training: Let’s Git It!
Mini-training: Let’s Git It!
Betclic Everest Group Tech Team
 
Git introduction
Git introductionGit introduction
Git introduction
satyendrajaladi
 
GitHub Event.pptx
GitHub Event.pptxGitHub Event.pptx
GitHub Event.pptx
KeerthanaJ32
 
Git and git workflow best practice
Git and git workflow best practiceGit and git workflow best practice
Git and git workflow best practice
Majid Hosseini
 
Git session Dropsolid.com
Git session Dropsolid.comGit session Dropsolid.com
Git session Dropsolid.com
dropsolid
 
Improving your workflow with git
Improving your workflow with gitImproving your workflow with git
Improving your workflow with git
Dídac Ríos
 
Bedjango talk about Git & GitHub
Bedjango talk about Git & GitHubBedjango talk about Git & GitHub
Bedjango talk about Git & GitHub
BeDjango
 
14 oct Git & GitHub.pptx
14 oct Git & GitHub.pptx14 oct Git & GitHub.pptx
14 oct Git & GitHub.pptx
GDSCGHRIETNagpur
 
Introduction to Git and Github
Introduction to Git and GithubIntroduction to Git and Github
Introduction to Git and Github
Md Atique Ahmed Ziad
 

Similar to Advanted git (20)

Git training v10
Git training v10Git training v10
Git training v10
 
Advanced Git Tutorial
Advanced Git TutorialAdvanced Git Tutorial
Advanced Git Tutorial
 
Git and github
Git and githubGit and github
Git and github
 
Git and Github
Git and GithubGit and Github
Git and Github
 
Git Commands Every Developer Should Know?
Git Commands Every Developer Should Know?Git Commands Every Developer Should Know?
Git Commands Every Developer Should Know?
 
Git hub
Git hubGit hub
Git hub
 
Github By Nyros Developer
Github By Nyros DeveloperGithub By Nyros Developer
Github By Nyros Developer
 
Git github
Git githubGit github
Git github
 
Learn Git - For Beginners and Intermediate levels
Learn Git - For Beginners and Intermediate levelsLearn Git - For Beginners and Intermediate levels
Learn Git - For Beginners and Intermediate levels
 
The Fundamentals of Git
The Fundamentals of GitThe Fundamentals of Git
The Fundamentals of Git
 
Git: Why And How to
Git: Why And How toGit: Why And How to
Git: Why And How to
 
Mini-training: Let’s Git It!
Mini-training: Let’s Git It!Mini-training: Let’s Git It!
Mini-training: Let’s Git It!
 
Git introduction
Git introductionGit introduction
Git introduction
 
GitHub Event.pptx
GitHub Event.pptxGitHub Event.pptx
GitHub Event.pptx
 
Git and git workflow best practice
Git and git workflow best practiceGit and git workflow best practice
Git and git workflow best practice
 
Git session Dropsolid.com
Git session Dropsolid.comGit session Dropsolid.com
Git session Dropsolid.com
 
Improving your workflow with git
Improving your workflow with gitImproving your workflow with git
Improving your workflow with git
 
Bedjango talk about Git & GitHub
Bedjango talk about Git & GitHubBedjango talk about Git & GitHub
Bedjango talk about Git & GitHub
 
14 oct Git & GitHub.pptx
14 oct Git & GitHub.pptx14 oct Git & GitHub.pptx
14 oct Git & GitHub.pptx
 
Introduction to Git and Github
Introduction to Git and GithubIntroduction to Git and Github
Introduction to Git and Github
 

Recently uploaded

みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
名前 です男
 
National Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practicesNational Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practices
Quotidiano Piemontese
 
Climate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing DaysClimate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing Days
Kari Kakkonen
 
GenAI Pilot Implementation in the organizations
GenAI Pilot Implementation in the organizationsGenAI Pilot Implementation in the organizations
GenAI Pilot Implementation in the organizations
kumardaparthi1024
 
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
Neo4j
 
20240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 202420240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 2024
Matthew Sinclair
 
Best 20 SEO Techniques To Improve Website Visibility In SERP
Best 20 SEO Techniques To Improve Website Visibility In SERPBest 20 SEO Techniques To Improve Website Visibility In SERP
Best 20 SEO Techniques To Improve Website Visibility In SERP
Pixlogix Infotech
 
“I’m still / I’m still / Chaining from the Block”
“I’m still / I’m still / Chaining from the Block”“I’m still / I’m still / Chaining from the Block”
“I’m still / I’m still / Chaining from the Block”
Claudio Di Ciccio
 
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
Edge AI and Vision Alliance
 
How to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptxHow to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptx
danishmna97
 
RESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for studentsRESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for students
KAMESHS29
 
How to use Firebase Data Connect For Flutter
How to use Firebase Data Connect For FlutterHow to use Firebase Data Connect For Flutter
How to use Firebase Data Connect For Flutter
Daiki Mogmet Ito
 
Introduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - CybersecurityIntroduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - Cybersecurity
mikeeftimakis1
 
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with SlackLet's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
shyamraj55
 
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdfUnlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Malak Abu Hammad
 
Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1
DianaGray10
 
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
Neo4j
 
Programming Foundation Models with DSPy - Meetup Slides
Programming Foundation Models with DSPy - Meetup SlidesProgramming Foundation Models with DSPy - Meetup Slides
Programming Foundation Models with DSPy - Meetup Slides
Zilliz
 
Infrastructure Challenges in Scaling RAG with Custom AI models
Infrastructure Challenges in Scaling RAG with Custom AI modelsInfrastructure Challenges in Scaling RAG with Custom AI models
Infrastructure Challenges in Scaling RAG with Custom AI models
Zilliz
 
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
Neo4j
 

Recently uploaded (20)

みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
 
National Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practicesNational Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practices
 
Climate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing DaysClimate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing Days
 
GenAI Pilot Implementation in the organizations
GenAI Pilot Implementation in the organizationsGenAI Pilot Implementation in the organizations
GenAI Pilot Implementation in the organizations
 
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
 
20240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 202420240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 2024
 
Best 20 SEO Techniques To Improve Website Visibility In SERP
Best 20 SEO Techniques To Improve Website Visibility In SERPBest 20 SEO Techniques To Improve Website Visibility In SERP
Best 20 SEO Techniques To Improve Website Visibility In SERP
 
“I’m still / I’m still / Chaining from the Block”
“I’m still / I’m still / Chaining from the Block”“I’m still / I’m still / Chaining from the Block”
“I’m still / I’m still / Chaining from the Block”
 
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
 
How to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptxHow to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptx
 
RESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for studentsRESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for students
 
How to use Firebase Data Connect For Flutter
How to use Firebase Data Connect For FlutterHow to use Firebase Data Connect For Flutter
How to use Firebase Data Connect For Flutter
 
Introduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - CybersecurityIntroduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - Cybersecurity
 
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with SlackLet's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
 
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdfUnlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
 
Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1
 
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
 
Programming Foundation Models with DSPy - Meetup Slides
Programming Foundation Models with DSPy - Meetup SlidesProgramming Foundation Models with DSPy - Meetup Slides
Programming Foundation Models with DSPy - Meetup Slides
 
Infrastructure Challenges in Scaling RAG with Custom AI models
Infrastructure Challenges in Scaling RAG with Custom AI modelsInfrastructure Challenges in Scaling RAG with Custom AI models
Infrastructure Challenges in Scaling RAG with Custom AI models
 
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
 

Advanted git

  • 2. WHAT IS GIT & IT’S ADVANTAGES ➤ Git is a version control system that helps you manage and save your changes over time. Developed in 2005 by Linus Torvalds, the famous creator of the Linux operating system kernel. Advantages: ➤ Complete long term change history for all file. ➤ Being able to trace each change made. ➤ Allow multiple team members to collaborate on same code. ➤ Provide backup copy.
  • 3. ` ➤ Git basics (Git setup and server integration). ➤ Git branches and merging. ➤ Undoing things (Manipulating git history snapshot). ➤ Making open source contribution. ➤ Various Git workflows & git hooks. ➤ Useful Git tools.
  • 4. GIT BASIC (GIT SETUP AND SERVER INTEGRATION) — Create a git repo. — Cloning a git repo. — Setting git config creating commands alias git config user.name git config user.name "Sahil Gupta" git config --global alias.ci commit git config credential.helper store — add changes to git repo. — checking git status — committing your changes. — Pushing your changes to remote. — Create new branches — checkout a new branch — Doing above 2 steps in one.
  • 5. GIT BASIC (GIT SETUP AND SERVER INTEGRATION) CONTINUED… — Fetching a remote changes. — Delete branches. — Stash changes — getting back the stash changes into any branch — checking git history GIT LOG: — git log , git log -n, git log -p, git log <file>, git log —graph, git log --graph --decorate --oneline, git log --author="Sahil”, git shortlog, git log --after="2014-7-1" --before="2014-7-4”, git log --author="John”, git log -- foo.py bar.py, git log master..feature Git Stash: — git stash, git stash save <msg>, git stash pop [stash@{2}], git stash apply, git stash list, git stash show, git stash show -p, git stash drop [stash@{2}], git stash clear
  • 6. GIT BASIC (GIT SETUP AND SERVER INTEGRATION) CONTINUED… GITIGNORE: — .gitignore [Use glowing pattern] **/logs .log /debug.log logs/ — adding comment # ignore all logs — Adding multiple .gitignore — Ignoring a previous committed files edit .gitignore && git rm --cached debug.log — *.log !debug.log. Ignore pattern with an exception — collection of useful gitignore templates https://github.com/github/gitignore
  • 7. GIT BRANCHES AND MERGING — Create a new branch. — Switch between the branches. — Delete unwanted branches. — How to move changes between branches. — rebase & merging — Merging branches. (i). Fast forward merging. (ii). 3 way merging. — what is —no-ff in merging — Merging specific commit git cherry-pick <SHA ID>
  • 8. UNDOING THINGS(VIEWING AND MANIPULATING HISTORY) — Viewing git history (git log). — Go back to some previous commit state. — How we run into “Detached Head” state. — Remove untracked changes. — Remove stagged changes. — Remove committed changes. — Remove commits from Remote branch. Associated Commands: checkout, clean,revert,reset
  • 9. MAKING OPEN SOURCE CONTRIBUTION — Fork a repo. — Clone local copy of Repo. — Make changes and push it to forked copy. — Create pull request. — Finally wait for approver to accept/reject your pull request.
  • 10. GIT WORFLOWS & GIT HOOKS Major different git workflow: — Centralised workflow. — Feature branches workflow. — Gitflow workflow. — Forking Workflow. Git Hooks: — scripts can be be written in any scripting languages. Most popular language used are shell, Python and perl. — First script line defines the interpreter #!/bin/sh : shell #!/usr/bin/env python : Pathon — Git hooks are local in scope. You can share it by adding it outside .git, template directory or creating sum links.
  • 11. Git hooks continued…. — Local Hooks • pre-commit • prepare-commit-msg • commit-msg • post-commit • post-checkout • pre-rebase — Server side Hooks: • pre-receive • update • post-receive
  • 12. GIT GUI TOOLS Built in tools: — gitk& git-gui Third Party Tools: — SourceTree — Meld — Git kraken Reference : https://git-scm.com/downloads/guis/
  • 13. GIT TIPS AND DISCUSSION — Difference between Fetch and Pull. — Difference between merge and rebase — Difference between git log and git status — Difference between git reset —hard vs git reset —soft vs git reset —mixed — Force push and issues in it. — How to combine multiple commit, git reset —soft <sha-1 hash> — Rewriting history/How to change last commit with new changes.