SlideShare a Scribd company logo
1 of 35
Download to read offline
Git Series. Episode 2
Merge. Upstream Commands. Tags
Mikhail Melnik, 2015
Merge
There are two types of merge:
fast-forward and “true merge”.
Fast-Forward
Fast-Forward
Fast-Forward
Fast-Forward
OR
True Merge
True Merge
True Merge
Merge Summary
There are two types of merge:
● fast-forward
● “true merge”
Merge Summary
There are two types of merge:
● fast-forward
● “true merge”
Fast-forward is the default.
Only when it fails, true merge is made.
Should be explicitly set for merge!
Pointers
Every local and remote branch
(master, origin/master, etc)
is just a pointer to certain commit that in turn
points to certain data snapshot.
The same thing for tags.
HEAD is special Git word that represents a pointer
to the current working tree state.
Upstreams
Upstream is a Git term describing the remote referenced object. For origin repo it means
source repository it was cloned from. For local branch it means referenced branch from
the remote repository.
You can watch these references using your favourite IDE or using a console Git command:
git branch -v
There are also Git aliases for it: @{upstream} or @{u}. It’s possible to use following syntax:
git fetch origin
git checkout production
git merge @{u} /* instead of ‘git merge origin/production’ */
Origin is an Alias
After we do “git clone” we get a local
copy of the remote repository that can be
referenced locally using certain alias.
“Origin” is an default alias, representing
repository if no other were set.
Similarly to it, “master” is the default
name for the first branch in the newly
created repository.
Origin is an Alias
All origin/* branches are not reachable
directly, so you cannot modify them.
Instead you have local branches that
were forked from one of the origin/*
branches that really are not branches on
the remote repository.
In fact, they are a remote branches copy
that exist in your repository clone.
And that repository clone has a reference
to the source repository.
Git Fetch
Fetch is a command for Git to update specified local repository with latest changes from its referenced upstream.
Git Fetch
Fetch is a command for Git to update specified local repository with latest changes from it’s referenced upstream.
Git Fetch
Fetch is a command for Git to update specified local repository with latest changes from it’s referenced upstream.
Git Pull
Pull is actually a combination of fetch and merge. Pull fetches the new data to your repository and merges your current
branch with it’s upstream.
Git Pull
Pull is actually a combination of fetch and merge. Pull fetches the new data to your repository and merges your current
branch with it’s upstream.
Git Pull
Pull is actually a combination of fetch and merge. Pull fetches the new data to your repository and merges your current
branch with it’s upstream.
Git Pull
Important thing for pull is
that it merges (updates with changes)
only the current branch you are on.
Don’t forget to update other branches
after switching to them!
Git Push
Push is a command for Git to publish commits, that were made on local branches to their upstreams. Publishing
changes does implicit fast-forward merge on the upstream repository.
Git Push
Push is a command for Git to publish commits, that were made on local branches to their upstreams. Publishing
changes does implicit fast-forward merge on the upstream repository.
Git Push
Push is a command for Git to publish commits, that were made on local branches to their upstreams. Publishing
changes does implicit fast-forward merge on the upstream repository.
Git Push
By default, Git publish changes
from all referenced branches.
Always explicitly specify the branch
what changes you want Git to publish.
And Be Careful of Force Push
And Be Careful of Force Push
And Be Careful of Force Push
Never use --force (-f) flag without specifying a certain branch name!
NEVER! Cause it may lead to data loss!
And Be Careful of Force Push
Whenever you do a force push
be sure
you shout a loud to your team about it.
Git Push
You can set default behaviour for push in the Git settings.
Git Push
There are a bunch of push.default politics you can chose from:
● nothing — do not push anything unless a refspec is explicitly given.
● current — push the current branch to update a branch with the same name on the receiving end.
● upstream — push the current branch to the branch whose changes are usually integrated into the current branch
(which is called @{upstream}).
● simple — works like upstream, but refuse to push if the upstream branch name is different.
● matching — push all branches having the same name on both ends.
Matching policy used to be the default until Git 2.0 came up.
Git Push
But I strongly recommend to be obvious and always set the branch name explicitly.
And Use the Tags
The simplest way to add new tag on current commit is
git tag v1.4
or
git tag -a v1.4 -m 'my version 1.4'
As it was said before in case of data/history loses
you can easily checkout your tag.
Of course if it wasn’t deleted by somebody :)
Links
Core Git sources:
1. Pro Git book
2. Git reference
3. Git magic
Step-by-step tutorials:
1. Nice online Git tutorial
2. Become a Git guru
Additional links:
1. Git visual reference
Feel free to mail me at mikhailimelnik@gmail.com.
Specific topics:
1. Git best practices
2. Upstream term discussion
3. Fast-forward problem

More Related Content

What's hot

Git tutorial git branches 20131206-Bryan
Git tutorial   git branches 20131206-BryanGit tutorial   git branches 20131206-Bryan
Git tutorial git branches 20131206-BryanLearningTech
 
Git and git workflow best practice
Git and git workflow best practiceGit and git workflow best practice
Git and git workflow best practiceMajid Hosseini
 
Workshop on Git and GitHub
Workshop on Git and GitHubWorkshop on Git and GitHub
Workshop on Git and GitHubDSCVSSUT
 
Git development workflow
Git development workflowGit development workflow
Git development workflowSankar Suda
 
Git Lab Introduction
Git Lab IntroductionGit Lab Introduction
Git Lab IntroductionKrunal Doshi
 
Git and github fundamentals
Git and github fundamentalsGit and github fundamentals
Git and github fundamentalsRajKharvar
 
Introduction to github slideshare
Introduction to github slideshareIntroduction to github slideshare
Introduction to github slideshareRakesh Sukumar
 
Git tutorial
Git tutorialGit tutorial
Git tutorialmobaires
 
Git usage (Basics and workflow)
Git usage (Basics and workflow)Git usage (Basics and workflow)
Git usage (Basics and workflow)Yeasin Abedin
 
CodeMontage CodeFlow 1
CodeMontage CodeFlow 1CodeMontage CodeFlow 1
CodeMontage CodeFlow 1CodeMontage
 
Introduction to Git
Introduction to GitIntroduction to Git
Introduction to GitRick Umali
 

What's hot (20)

Git
GitGit
Git
 
Git & Github
Git & GithubGit & Github
Git & Github
 
Git n git hub
Git n git hubGit n git hub
Git n git hub
 
Git tutorial git branches 20131206-Bryan
Git tutorial   git branches 20131206-BryanGit tutorial   git branches 20131206-Bryan
Git tutorial git branches 20131206-Bryan
 
Git Tricks
Git TricksGit Tricks
Git Tricks
 
Git and git workflow best practice
Git and git workflow best practiceGit and git workflow best practice
Git and git workflow best practice
 
Workshop on Git and GitHub
Workshop on Git and GitHubWorkshop on Git and GitHub
Workshop on Git and GitHub
 
Git Pull Requests
Git Pull RequestsGit Pull Requests
Git Pull Requests
 
Introduction to Git
Introduction to GitIntroduction to Git
Introduction to Git
 
Git development workflow
Git development workflowGit development workflow
Git development workflow
 
Git Lab Introduction
Git Lab IntroductionGit Lab Introduction
Git Lab Introduction
 
Git and github fundamentals
Git and github fundamentalsGit and github fundamentals
Git and github fundamentals
 
git-flow R3Labs
git-flow R3Labsgit-flow R3Labs
git-flow R3Labs
 
Git 101
Git 101Git 101
Git 101
 
Introduction to github slideshare
Introduction to github slideshareIntroduction to github slideshare
Introduction to github slideshare
 
Git tutorial
Git tutorialGit tutorial
Git tutorial
 
Git usage (Basics and workflow)
Git usage (Basics and workflow)Git usage (Basics and workflow)
Git usage (Basics and workflow)
 
CodeMontage CodeFlow 1
CodeMontage CodeFlow 1CodeMontage CodeFlow 1
CodeMontage CodeFlow 1
 
Introduction to Git
Introduction to GitIntroduction to Git
Introduction to Git
 
Subversion to Git Migration
Subversion to Git MigrationSubversion to Git Migration
Subversion to Git Migration
 

Similar to Git Series. Episode 2. Merge, Upstream Commands and Tags

Effective Git with Eclipse
Effective Git with EclipseEffective Git with Eclipse
Effective Git with EclipseChris Aniszczyk
 
Git basics with notes
Git basics with notesGit basics with notes
Git basics with notesSurabhi Gupta
 
Version Control System - Git
Version Control System - GitVersion Control System - Git
Version Control System - GitCarlo Bernaschina
 
Git-ing out of your git messes
Git-ing out of  your git messesGit-ing out of  your git messes
Git-ing out of your git messesKatie Sylor-Miller
 
Improving your workflow with git
Improving your workflow with gitImproving your workflow with git
Improving your workflow with gitDídac Ríos
 
Hacktoberfest intro to Git and GitHub
Hacktoberfest intro to Git and GitHubHacktoberfest intro to Git and GitHub
Hacktoberfest intro to Git and GitHubDSC GVP
 
Git Tutorial For Beginners | What is Git and GitHub? | DevOps Tools | DevOps ...
Git Tutorial For Beginners | What is Git and GitHub? | DevOps Tools | DevOps ...Git Tutorial For Beginners | What is Git and GitHub? | DevOps Tools | DevOps ...
Git Tutorial For Beginners | What is Git and GitHub? | DevOps Tools | DevOps ...Simplilearn
 
Introducing Git and git flow
Introducing Git and git flow Introducing Git and git flow
Introducing Git and git flow Sebin Benjamin
 
Nina Zakharenko - Introduction to Git - Start SLC 2015
Nina Zakharenko - Introduction to Git - Start SLC 2015Nina Zakharenko - Introduction to Git - Start SLC 2015
Nina Zakharenko - Introduction to Git - Start SLC 2015Nina Zakharenko
 
How to Really Get Git
How to Really Get GitHow to Really Get Git
How to Really Get GitSusan Tan
 
Introduction to Git for Artists
Introduction to Git for ArtistsIntroduction to Git for Artists
Introduction to Git for ArtistsDavid Newbury
 
Use git the proper way
Use git the proper wayUse git the proper way
Use git the proper wayJaime Buelta
 

Similar to Git Series. Episode 2. Merge, Upstream Commands and Tags (20)

Effective Git with Eclipse
Effective Git with EclipseEffective Git with Eclipse
Effective Git with Eclipse
 
Git basics with notes
Git basics with notesGit basics with notes
Git basics with notes
 
Version Control System - Git
Version Control System - GitVersion Control System - Git
Version Control System - Git
 
Git-ing out of your git messes
Git-ing out of  your git messesGit-ing out of  your git messes
Git-ing out of your git messes
 
Improving your workflow with git
Improving your workflow with gitImproving your workflow with git
Improving your workflow with git
 
Mastering GIT
Mastering GITMastering GIT
Mastering GIT
 
Git tutorial
Git tutorialGit tutorial
Git tutorial
 
Git like a pro EDD18 - Full edition
Git like a pro EDD18 - Full editionGit like a pro EDD18 - Full edition
Git like a pro EDD18 - Full edition
 
Hacktoberfest intro to Git and GitHub
Hacktoberfest intro to Git and GitHubHacktoberfest intro to Git and GitHub
Hacktoberfest intro to Git and GitHub
 
Git
GitGit
Git
 
Getting Git Right
Getting Git Right Getting Git Right
Getting Git Right
 
Git Tutorial For Beginners | What is Git and GitHub? | DevOps Tools | DevOps ...
Git Tutorial For Beginners | What is Git and GitHub? | DevOps Tools | DevOps ...Git Tutorial For Beginners | What is Git and GitHub? | DevOps Tools | DevOps ...
Git Tutorial For Beginners | What is Git and GitHub? | DevOps Tools | DevOps ...
 
Introducing Git and git flow
Introducing Git and git flow Introducing Git and git flow
Introducing Git and git flow
 
Git&GitHub.pptx
Git&GitHub.pptxGit&GitHub.pptx
Git&GitHub.pptx
 
Nina Zakharenko - Introduction to Git - Start SLC 2015
Nina Zakharenko - Introduction to Git - Start SLC 2015Nina Zakharenko - Introduction to Git - Start SLC 2015
Nina Zakharenko - Introduction to Git - Start SLC 2015
 
How to Really Get Git
How to Really Get GitHow to Really Get Git
How to Really Get Git
 
Git and GitHub
Git and GitHubGit and GitHub
Git and GitHub
 
Introduction to Git (part 2)
Introduction to Git (part 2)Introduction to Git (part 2)
Introduction to Git (part 2)
 
Introduction to Git for Artists
Introduction to Git for ArtistsIntroduction to Git for Artists
Introduction to Git for Artists
 
Use git the proper way
Use git the proper wayUse git the proper way
Use git the proper way
 

Recently uploaded

Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsArshad QA
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfkalichargn70th171
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantAxelRicardoTrocheRiq
 
Clustering techniques data mining book ....
Clustering techniques data mining book ....Clustering techniques data mining book ....
Clustering techniques data mining book ....ShaimaaMohamedGalal
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionSolGuruz
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...panagenda
 
Test Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and BackendTest Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and BackendArshad QA
 
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AISyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AIABDERRAOUF MEHENNI
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsAlberto González Trastoy
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsJhone kinadey
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...MyIntelliSource, Inc.
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...gurkirankumar98700
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsAndolasoft Inc
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxComplianceQuest1
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerThousandEyes
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️Delhi Call girls
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...MyIntelliSource, Inc.
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Steffen Staab
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providermohitmore19
 

Recently uploaded (20)

Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service Consultant
 
Clustering techniques data mining book ....
Clustering techniques data mining book ....Clustering techniques data mining book ....
Clustering techniques data mining book ....
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with Precision
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 
Test Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and BackendTest Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and Backend
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AISyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.js
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docx
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 

Git Series. Episode 2. Merge, Upstream Commands and Tags

  • 1. Git Series. Episode 2 Merge. Upstream Commands. Tags Mikhail Melnik, 2015
  • 2. Merge There are two types of merge: fast-forward and “true merge”.
  • 10. Merge Summary There are two types of merge: ● fast-forward ● “true merge”
  • 11. Merge Summary There are two types of merge: ● fast-forward ● “true merge” Fast-forward is the default. Only when it fails, true merge is made. Should be explicitly set for merge!
  • 12. Pointers Every local and remote branch (master, origin/master, etc) is just a pointer to certain commit that in turn points to certain data snapshot. The same thing for tags. HEAD is special Git word that represents a pointer to the current working tree state.
  • 13. Upstreams Upstream is a Git term describing the remote referenced object. For origin repo it means source repository it was cloned from. For local branch it means referenced branch from the remote repository. You can watch these references using your favourite IDE or using a console Git command: git branch -v There are also Git aliases for it: @{upstream} or @{u}. It’s possible to use following syntax: git fetch origin git checkout production git merge @{u} /* instead of ‘git merge origin/production’ */
  • 14. Origin is an Alias After we do “git clone” we get a local copy of the remote repository that can be referenced locally using certain alias. “Origin” is an default alias, representing repository if no other were set. Similarly to it, “master” is the default name for the first branch in the newly created repository.
  • 15. Origin is an Alias All origin/* branches are not reachable directly, so you cannot modify them. Instead you have local branches that were forked from one of the origin/* branches that really are not branches on the remote repository. In fact, they are a remote branches copy that exist in your repository clone. And that repository clone has a reference to the source repository.
  • 16. Git Fetch Fetch is a command for Git to update specified local repository with latest changes from its referenced upstream.
  • 17. Git Fetch Fetch is a command for Git to update specified local repository with latest changes from it’s referenced upstream.
  • 18. Git Fetch Fetch is a command for Git to update specified local repository with latest changes from it’s referenced upstream.
  • 19. Git Pull Pull is actually a combination of fetch and merge. Pull fetches the new data to your repository and merges your current branch with it’s upstream.
  • 20. Git Pull Pull is actually a combination of fetch and merge. Pull fetches the new data to your repository and merges your current branch with it’s upstream.
  • 21. Git Pull Pull is actually a combination of fetch and merge. Pull fetches the new data to your repository and merges your current branch with it’s upstream.
  • 22. Git Pull Important thing for pull is that it merges (updates with changes) only the current branch you are on. Don’t forget to update other branches after switching to them!
  • 23. Git Push Push is a command for Git to publish commits, that were made on local branches to their upstreams. Publishing changes does implicit fast-forward merge on the upstream repository.
  • 24. Git Push Push is a command for Git to publish commits, that were made on local branches to their upstreams. Publishing changes does implicit fast-forward merge on the upstream repository.
  • 25. Git Push Push is a command for Git to publish commits, that were made on local branches to their upstreams. Publishing changes does implicit fast-forward merge on the upstream repository.
  • 26. Git Push By default, Git publish changes from all referenced branches. Always explicitly specify the branch what changes you want Git to publish.
  • 27. And Be Careful of Force Push
  • 28. And Be Careful of Force Push
  • 29. And Be Careful of Force Push Never use --force (-f) flag without specifying a certain branch name! NEVER! Cause it may lead to data loss!
  • 30. And Be Careful of Force Push Whenever you do a force push be sure you shout a loud to your team about it.
  • 31. Git Push You can set default behaviour for push in the Git settings.
  • 32. Git Push There are a bunch of push.default politics you can chose from: ● nothing — do not push anything unless a refspec is explicitly given. ● current — push the current branch to update a branch with the same name on the receiving end. ● upstream — push the current branch to the branch whose changes are usually integrated into the current branch (which is called @{upstream}). ● simple — works like upstream, but refuse to push if the upstream branch name is different. ● matching — push all branches having the same name on both ends. Matching policy used to be the default until Git 2.0 came up.
  • 33. Git Push But I strongly recommend to be obvious and always set the branch name explicitly.
  • 34. And Use the Tags The simplest way to add new tag on current commit is git tag v1.4 or git tag -a v1.4 -m 'my version 1.4' As it was said before in case of data/history loses you can easily checkout your tag. Of course if it wasn’t deleted by somebody :)
  • 35. Links Core Git sources: 1. Pro Git book 2. Git reference 3. Git magic Step-by-step tutorials: 1. Nice online Git tutorial 2. Become a Git guru Additional links: 1. Git visual reference Feel free to mail me at mikhailimelnik@gmail.com. Specific topics: 1. Git best practices 2. Upstream term discussion 3. Fast-forward problem