SlideShare a Scribd company logo
Xx de enero de 2010 Use git without rage
“VCS should be a subject in informatics” Heared about VCS
“ We use VCS as if we were trained monkeys” Heared about VCS
Types of VCS LVCS (Localized VCS) CVCS (Centralized VCS) DVCS (Distributed VCS)
LVCS cp -r project projectB
rcs (mac os)
CVCS (Centralized VCS) SVN
CVS
DVCS (Distributed VCS) Git
Mercurial
Git Basics
First-time git setup Three places System: git config --system (/etc/gitconfig)
Global: git config --global (~/.gitconfig)
Local: git config (cwd) git config [--system | --local] property value
git config --global user.name 'wadus'
Git Basics
File status cycle untracked staged modified unmodified git add edit git add git commit git commit -a
Workflows Scenario 1: Creating a repository from the beginnig and working with it (with no rage)
Scenario 1: creating the repository  git init (from directory project) Pffffff... this was hard!!!!
Workflows -Scenario 1: edit some files Edit and/or create some files for your project this is what developing is about in last term, isn't it?
Workflows -Scenario 1: commiting changes So, now you want to commit changes, but first... some advices for those who are used to working with CSCVs such as svn or cvs 100.times do puts “I will think in local terms, 'cos I am not working with remotes (yet)” end
Workflows - Scenario 1: adding files to the staging area git status git add <file>  -> add files to staging area (either new or modified files) Wow!!! I could not have imagined it!!!!
Workflows – Scenario 1: Removing files from the staging area Damn it!!! I staged some files I didn't have to git reset HEAD <file> Phewwww!!!!
Workflows – Scenario 1: What am I about to commit? Ok, I want to commit my changes, but which files I am about to commit? git status git diff (for unstaged files) git diff --cached (for staged files)
Workflows – Scenario 1: Let's commit!!! git commit  -> it will commit all the files in staging area git commit <filename>  -> it will commit named files git commit -a  -> it will commit all modified files skipping the staging area for those which are not staged
Workflows – Scenario 1: deleting files rm <filename>  removes file manually git rm <filename>  stages deletion ...or... git rm <filename>  will do both things
Workflows – Scenario 1: undeleting files git status  will give you clues if deletion is in the staging area git reset HEAD <filename> if deletion is not in the staging area git checkout <filename>
Workflows – Scenario 1: moving files mv filename filename2 git rm filename git add filename2 ...or... git mv filename filename2
Workfows- Scenario 1: undoing things git commit --amend  will modify last commit git commit “ OMG, WTF, damn it!!! I forgot to add a file” git add damned_file git commit --ammend “ commit --amend FTW!!!”
Workfows- Scenario 1: undoing things (ii) Unstaging a staged file git reset HEAD filename Unmodify a modified and unstaged file git checkout filename
Workflows Scenario 2: working with remotes
Workfows- Scenario 2: adding a remote So I want to work with another repo... git remote add [shortname] [url] git remote add origin your_url Now I finally understand what I've been doing with github all this time!!!
Workfows- Scenario 2: showing your remotes If you want to know which repos you are working with: git remote git remote -v
Workfows- Scenario 2: fetching and pulling To get data from your remotes git fetch [remote-name] git pull [remote-name] fetch or pull??? pull = fetch + merge
Workfows- Scenario 2: pushing If you want to share your data: git push [remote-name] [branch]
Workfows- Scenario 2: inspecting a remote git remote show [remote-name] Look at the “Local ref configured for git push” Local refs configured for 'git push': master pushes to master (local out of date) test  pushes to test  (up to date)
Workfows- Scenario 2: removing and renaming remotes git remote rename [original-name] [new-name] git remote rm [remote-name] This changes take effect on your LOCAL repo (remember: local, local, local)
Workflows Scenario 3: tagging
Workfows- Scenario 3: listing tags git tag
Workfows- Scenario 3: tag types 2 types of tags:  lightweight  and  annotated Lightweight:  It is like a branch that doesn't change, a pointer to a specific commit Annotated:  These are stored as full objects. Checksumed and metadata are included
Workfows- Scenario 3: Creating and showing tags Annotated: git tag -a [tag] Lightweight: git tag [tag] git show [tag]
Workfows- Scenario 3: Creating tags later git tag -a <tag> <(part of) checksum of the commit>
Workfows- Scenario 3: Sharing tags When pushing, you do not share tags git push origin [tagname] Hey! This is like sharing branches... git push origin --tags  shares all the tags
Branching: the beginning of magic Please, keep on thinking in local... or I will send @pacoguzman to kill you!!!
Branching: the beginning of magic Let's do some review... git add README test.rb LICENSE git commit -m 'initial commit of my project' How is this commit stored?
Branching: the beginning of magic taken from http://progit.org/
Branching: the beginning of magic Let's assume we keep on doing some commits
Branching: the beginning of magic taken from http://progit.org/
Branching: the beginning of magic I thought we were going to talk about branches, you son of the bit!!!
Branching: the beginning of magic I thought we were going to talk about branches, you  son of the bit !!! A very bad geek joke
Branching: the beginning of magic Branch: A movable pointer to one of these commits. Do you smell it??? Yeah! And it seems that it's going to taste even better!
Branching: the beginning of magic taken from http://progit.org/
Branching: the beginning of magic So... let's imagine we want to make a new branch: git branch testing
Branching: the beginning of magic taken from http://progit.org/
Branching: the beginning of magic Hey! But somehow I have to know wich branch I am at, aren't I???
Branching: the beginning of magic taken from http://progit.org/
Branching: the beginning of magic git checkout testing
Branching: the beginning of magic taken from http://progit.org/
Branching: the beginning of magic Very pretty... but... how the hell is this supposed to be useful???
Branching: the beginning of magic touch newfile.txt git commit -a -m 'new file'
Branching: the beginning of magic taken from http://progit.org/
Branching: the beginning of magic git checkout master
Branching: the beginning of magic taken from http://progit.org/
Branching: the beginning of magic touch another_file.txt git commit -a -m 'another new file in master branch'
Branching: the beginning of magic taken from http://progit.org/
Workflows Scenario 4: working with branches
Scenario 4: Context You are working on a new story, comfortably and peacefully when suddenly you receive a call –  OMG! and you are told that it is urgent - but surely not important - to fix some bug in the application (e.g: to change some text which only appears in that last screen of your app)
Scenario 4: steps resume Create a branch for the new story you are going to work on
Do some work on that branch
Swear after you receive that f*ck*ng damned call
Commit or stash all the changes that you haven't saved yet – if you want to -
Checkout your production (usually master) branch
Create a branch to add the hotfix
Fix that so f*ck*ng urgent issue
Merge this branch and push it to production
Switch back to your original story and continue working on it
Scenario 4: the process git checkout master -b issue_1 C1 C3 C2 master * issue_1
Scenario 4: the process make some changes and commit them C1 C3 C2 master * issue_1 C4
Scenario 4: the process Create a new branch from master for that hotfix git checkout master -b hotfix C1 C3 C2 master issue_1 C4 * hotfix
Scenario 4: the process Fix the problem and commit changes C1 C3 C2 master issue_1 C4 * hotfix C5
Scenario 4: fast forward merge Merge hotfix into master git checkout master git merge hotfix C1 C3 C2 * master issue_1 C4 hotfix C5
Scenario 4: fast forward merge What kind of merge is this!!! You have done nothing but moving forward master pointer C1 C3 C2 * master issue_1 C4 hotfix C5
Scenario 4: the process End issue_1 and commit changes C1 C3 C2 * master issue_1 C4 hotfix C5 C6
Scenario 4: three way merge Merge changes git checkout master git merge issue_1 C3 issue_1 C4 hotfix C5 C6 * master
Scenario 4: three way merge Merge changes git checkout master git merge issue_1 C3 * master issue_1 C4 hotfix C5 C6 C7
Scenario 4: merge conflicts If there are merge conflicts you have to solve them manually. Once you have resolved them, you can set these files as merged with git add <filename> git commit
Scenario 4: branch management git branch  lists branches git branch -v  lists branches with their last commit git branch --merged  lists merged branches git branch --no-merged  lists unmerged branches git branch -d <branchname>  deletes merged branch (-D for unmerged branches)
Branching workflows
Branching workflows: long running branches taken from http://progit.org/
Branching workflows: topic branches taken from http://progit.org/
Branching workflows: topic branches Merge iss91v2 and dumbidea taken from http://progit.org/
Remote branches References to the state of branches on your remote repos They are local branches which you can not move. They are moved automatically whenever you do any network communication
Pushing branches git push <remote> <branch> [:server_branch_name] git push origin my_local_branch:server_branch
Deleting remote branches git push origin :branch_to_be_deleted It's like git push origin (nothing):branch_to_be_deleted
Tracking branches Checking out a remote branch, will create a tracking branch. With tracking branches you can call git push git pull without remote or branches names When you clone a repo, a local branch “master” is created, which tracks origin/master
Rebasing
Basic rebasing vs merge This is what we already know git merge experiment taken from http://progit.org/
Basic rebasing vs merge And this is rebasing git rebase master experiment   or... git checkout experiment git rebase master
Basic rebasing vs merge taken from http://progit.org/
Basic rebasing vs merge It gets the diffs introduced by each commit of the branch you're on. It saves those diffs to temporary files It resets the current branch to the common ancestor with the branch you are rebasing onto It applies these changes and creates a new commit
Basic rebasing vs merge Now, you can do a fast forward merge taken from http://progit.org/
Rebasing onto other branches taken from http://progit.org/
Rebasing onto other branches git rebase --onto master server client taken from http://progit.org/
Rebasing onto other branches git checkout master git merge client taken from http://progit.org/
Rebasing onto other branches git rebase master server taken from http://progit.org/
Rebasing or not rebasing? Be very careful when rebasing commits published in a public repository... …you could be killed by other developers
Rebasing or not rebasing? taken from http://progit.org/
Rebasing or not rebasing? Fetch changes in remote repo taken from http://progit.org/
Rebasing or not rebasing? Someone rebased changes (C4 – C6) taken from http://progit.org/
Rebasing or not rebasing? C4 and C4' introduce the same changes taken from http://progit.org/
DISTRIBUTED WORKFLOWS
Centralized workflow (small teams) taken from http://progit.org/
Ad

More Related Content

What's hot (20)

Git - Get Ready To Use It
Git - Get Ready To Use ItGit - Get Ready To Use It
Git - Get Ready To Use It
Daniel Kummer
 
Git internals
Git internalsGit internals
Git internals
Haggai Philip Zagury
 
Versions
VersionsVersions
Versions
Olivier DELHOMME
 
Getting some Git
Getting some GitGetting some Git
Getting some Git
BADR
 
GIT in a nutshell
GIT in a nutshellGIT in a nutshell
GIT in a nutshell
alignan
 
Git real slides
Git real slidesGit real slides
Git real slides
Lucas Couto
 
Git and github - Verson Control for the Modern Developer
Git and github - Verson Control for the Modern DeveloperGit and github - Verson Control for the Modern Developer
Git and github - Verson Control for the Modern Developer
John Stevenson
 
Learning Git with Workflows
Learning Git with WorkflowsLearning Git with Workflows
Learning Git with Workflows
Mosky Liu
 
PuppetConf 2014 Killer R10K Workflow With Notes
PuppetConf 2014 Killer R10K Workflow With NotesPuppetConf 2014 Killer R10K Workflow With Notes
PuppetConf 2014 Killer R10K Workflow With Notes
Phil Zimmerman
 
Git & GitHub WorkShop
Git & GitHub WorkShopGit & GitHub WorkShop
Git & GitHub WorkShop
SheilaJimenezMorejon
 
Advanced Git
Advanced GitAdvanced Git
Advanced Git
Sergiu-Ioan Ungur
 
Continuous Delivery of Puppet Manifests
Continuous Delivery of Puppet ManifestsContinuous Delivery of Puppet Manifests
Continuous Delivery of Puppet Manifests
Kris Buytaert
 
How to Really Get Git
How to Really Get GitHow to Really Get Git
How to Really Get Git
Susan Tan
 
Learn Git Basics
Learn Git BasicsLearn Git Basics
Learn Git Basics
Prakash Dantuluri
 
Grokking opensource with github
Grokking opensource with githubGrokking opensource with github
Grokking opensource with github
GoogleDeveloperStude4
 
Git - a powerful version control tool
Git - a powerful version control toolGit - a powerful version control tool
Git - a powerful version control tool
Kuo-Le Mei
 
Introduction to Griffon
Introduction to GriffonIntroduction to Griffon
Introduction to Griffon
James Williams
 
groovy & grails - lecture 10
groovy & grails - lecture 10groovy & grails - lecture 10
groovy & grails - lecture 10
Alexandre Masselot
 
Git in a nutshell
Git in a nutshellGit in a nutshell
Git in a nutshell
Pranesh Vittal
 
Ankara jug mayıs 2013 sunumu
Ankara jug mayıs 2013 sunumuAnkara jug mayıs 2013 sunumu
Ankara jug mayıs 2013 sunumu
Ankara JUG
 
Git - Get Ready To Use It
Git - Get Ready To Use ItGit - Get Ready To Use It
Git - Get Ready To Use It
Daniel Kummer
 
Getting some Git
Getting some GitGetting some Git
Getting some Git
BADR
 
GIT in a nutshell
GIT in a nutshellGIT in a nutshell
GIT in a nutshell
alignan
 
Git and github - Verson Control for the Modern Developer
Git and github - Verson Control for the Modern DeveloperGit and github - Verson Control for the Modern Developer
Git and github - Verson Control for the Modern Developer
John Stevenson
 
Learning Git with Workflows
Learning Git with WorkflowsLearning Git with Workflows
Learning Git with Workflows
Mosky Liu
 
PuppetConf 2014 Killer R10K Workflow With Notes
PuppetConf 2014 Killer R10K Workflow With NotesPuppetConf 2014 Killer R10K Workflow With Notes
PuppetConf 2014 Killer R10K Workflow With Notes
Phil Zimmerman
 
Continuous Delivery of Puppet Manifests
Continuous Delivery of Puppet ManifestsContinuous Delivery of Puppet Manifests
Continuous Delivery of Puppet Manifests
Kris Buytaert
 
How to Really Get Git
How to Really Get GitHow to Really Get Git
How to Really Get Git
Susan Tan
 
Git - a powerful version control tool
Git - a powerful version control toolGit - a powerful version control tool
Git - a powerful version control tool
Kuo-Le Mei
 
Introduction to Griffon
Introduction to GriffonIntroduction to Griffon
Introduction to Griffon
James Williams
 
Ankara jug mayıs 2013 sunumu
Ankara jug mayıs 2013 sunumuAnkara jug mayıs 2013 sunumu
Ankara jug mayıs 2013 sunumu
Ankara JUG
 

Similar to How to use git without rage (20)

Introduction to Git (Greg Lonnon)
Introduction to Git (Greg Lonnon)Introduction to Git (Greg Lonnon)
Introduction to Git (Greg Lonnon)
Boise Web Technologies Group
 
Git Started With Git
Git Started With GitGit Started With Git
Git Started With Git
Nick Quaranto
 
Introduction to Git for Artists
Introduction to Git for ArtistsIntroduction to Git for Artists
Introduction to Git for Artists
David Newbury
 
Git - (a) Gentle InTroduction
Git - (a) Gentle InTroductionGit - (a) Gentle InTroduction
Git - (a) Gentle InTroduction
Bruno Bossola
 
Wokshop de Git
Wokshop de Git Wokshop de Git
Wokshop de Git
Alberto Leal
 
Git 入门 与 实践
Git 入门 与 实践Git 入门 与 实践
Git 入门 与 实践
Terry Wang
 
Git
GitGit
Git
Terry Wang
 
Git 入门与实践
Git 入门与实践Git 入门与实践
Git 入门与实践
Terry Wang
 
Jedi Mind Tricks in Git
Jedi Mind Tricks in GitJedi Mind Tricks in Git
Jedi Mind Tricks in Git
Johan Abildskov
 
Git Distributed Version Control System
Git   Distributed Version Control SystemGit   Distributed Version Control System
Git Distributed Version Control System
Victor Wong
 
Jedi Mind Tricks for Git
Jedi Mind Tricks for GitJedi Mind Tricks for Git
Jedi Mind Tricks for Git
Jan Krag
 
Git
GitGit
Git
IT Booze
 
Mastering git - Workflow
Mastering git - WorkflowMastering git - Workflow
Mastering git - Workflow
Tahsin Abrar
 
Loading...git
Loading...gitLoading...git
Loading...git
Rafael García
 
Git For The Android Developer
Git For The Android DeveloperGit For The Android Developer
Git For The Android Developer
Effective
 
GDSC GIT AND GITHUB
GDSC GIT AND GITHUB GDSC GIT AND GITHUB
GDSC GIT AND GITHUB
GDSCIIITDHARWAD
 
Git in 10 minutes
Git in 10 minutesGit in 10 minutes
Git in 10 minutes
Safique Ahmed Faruque
 
Presentacion git
Presentacion gitPresentacion git
Presentacion git
Ignacio Martín
 
Git Tech Talk
Git  Tech TalkGit  Tech Talk
Git Tech Talk
Chris Johnson
 
Introduction To Git Workshop
Introduction To Git WorkshopIntroduction To Git Workshop
Introduction To Git Workshop
themystic_ca
 
Git Started With Git
Git Started With GitGit Started With Git
Git Started With Git
Nick Quaranto
 
Introduction to Git for Artists
Introduction to Git for ArtistsIntroduction to Git for Artists
Introduction to Git for Artists
David Newbury
 
Git - (a) Gentle InTroduction
Git - (a) Gentle InTroductionGit - (a) Gentle InTroduction
Git - (a) Gentle InTroduction
Bruno Bossola
 
Git 入门 与 实践
Git 入门 与 实践Git 入门 与 实践
Git 入门 与 实践
Terry Wang
 
Git 入门与实践
Git 入门与实践Git 入门与实践
Git 入门与实践
Terry Wang
 
Git Distributed Version Control System
Git   Distributed Version Control SystemGit   Distributed Version Control System
Git Distributed Version Control System
Victor Wong
 
Jedi Mind Tricks for Git
Jedi Mind Tricks for GitJedi Mind Tricks for Git
Jedi Mind Tricks for Git
Jan Krag
 
Mastering git - Workflow
Mastering git - WorkflowMastering git - Workflow
Mastering git - Workflow
Tahsin Abrar
 
Git For The Android Developer
Git For The Android DeveloperGit For The Android Developer
Git For The Android Developer
Effective
 
Introduction To Git Workshop
Introduction To Git WorkshopIntroduction To Git Workshop
Introduction To Git Workshop
themystic_ca
 
Ad

More from Javier Lafora Rey (8)

An introduction to Vue.js
An introduction to Vue.jsAn introduction to Vue.js
An introduction to Vue.js
Javier Lafora Rey
 
Modular development with redux
Modular development with reduxModular development with redux
Modular development with redux
Javier Lafora Rey
 
Understanding big data-drupalcamp
Understanding big data-drupalcampUnderstanding big data-drupalcamp
Understanding big data-drupalcamp
Javier Lafora Rey
 
API REST for beginners or why you should make your API understandable
API REST for beginners or why you should make your API understandableAPI REST for beginners or why you should make your API understandable
API REST for beginners or why you should make your API understandable
Javier Lafora Rey
 
APIs para gente normal
APIs para gente normalAPIs para gente normal
APIs para gente normal
Javier Lafora Rey
 
¿Por qué ruby on rails?
¿Por qué ruby on rails?¿Por qué ruby on rails?
¿Por qué ruby on rails?
Javier Lafora Rey
 
Ruby object model: A matter of life and death
Ruby object model: A matter of life and deathRuby object model: A matter of life and death
Ruby object model: A matter of life and death
Javier Lafora Rey
 
ROA - Resource Oriented Architecture
ROA - Resource Oriented ArchitectureROA - Resource Oriented Architecture
ROA - Resource Oriented Architecture
Javier Lafora Rey
 
Modular development with redux
Modular development with reduxModular development with redux
Modular development with redux
Javier Lafora Rey
 
Understanding big data-drupalcamp
Understanding big data-drupalcampUnderstanding big data-drupalcamp
Understanding big data-drupalcamp
Javier Lafora Rey
 
API REST for beginners or why you should make your API understandable
API REST for beginners or why you should make your API understandableAPI REST for beginners or why you should make your API understandable
API REST for beginners or why you should make your API understandable
Javier Lafora Rey
 
Ruby object model: A matter of life and death
Ruby object model: A matter of life and deathRuby object model: A matter of life and death
Ruby object model: A matter of life and death
Javier Lafora Rey
 
ROA - Resource Oriented Architecture
ROA - Resource Oriented ArchitectureROA - Resource Oriented Architecture
ROA - Resource Oriented Architecture
Javier Lafora Rey
 
Ad

Recently uploaded (20)

Leading AI Innovation As A Product Manager - Michael Jidael
Leading AI Innovation As A Product Manager - Michael JidaelLeading AI Innovation As A Product Manager - Michael Jidael
Leading AI Innovation As A Product Manager - Michael Jidael
Michael Jidael
 
Technology Trends in 2025: AI and Big Data Analytics
Technology Trends in 2025: AI and Big Data AnalyticsTechnology Trends in 2025: AI and Big Data Analytics
Technology Trends in 2025: AI and Big Data Analytics
InData Labs
 
How Can I use the AI Hype in my Business Context?
How Can I use the AI Hype in my Business Context?How Can I use the AI Hype in my Business Context?
How Can I use the AI Hype in my Business Context?
Daniel Lehner
 
"PHP and MySQL CRUD Operations for Student Management System"
"PHP and MySQL CRUD Operations for Student Management System""PHP and MySQL CRUD Operations for Student Management System"
"PHP and MySQL CRUD Operations for Student Management System"
Jainul Musani
 
Buckeye Dreamin 2024: Assessing and Resolving Technical Debt
Buckeye Dreamin 2024: Assessing and Resolving Technical DebtBuckeye Dreamin 2024: Assessing and Resolving Technical Debt
Buckeye Dreamin 2024: Assessing and Resolving Technical Debt
Lynda Kane
 
Automation Dreamin': Capture User Feedback From Anywhere
Automation Dreamin': Capture User Feedback From AnywhereAutomation Dreamin': Capture User Feedback From Anywhere
Automation Dreamin': Capture User Feedback From Anywhere
Lynda Kane
 
AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...
AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...
AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...
SOFTTECHHUB
 
2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx
Samuele Fogagnolo
 
Linux Professional Institute LPIC-1 Exam.pdf
Linux Professional Institute LPIC-1 Exam.pdfLinux Professional Institute LPIC-1 Exam.pdf
Linux Professional Institute LPIC-1 Exam.pdf
RHCSA Guru
 
Build Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For DevsBuild Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For Devs
Brian McKeiver
 
AI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global TrendsAI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global Trends
InData Labs
 
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath MaestroDev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
UiPathCommunity
 
tecnologias de las primeras civilizaciones.pdf
tecnologias de las primeras civilizaciones.pdftecnologias de las primeras civilizaciones.pdf
tecnologias de las primeras civilizaciones.pdf
fjgm517
 
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdfThe Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
Abi john
 
Learn the Basics of Agile Development: Your Step-by-Step Guide
Learn the Basics of Agile Development: Your Step-by-Step GuideLearn the Basics of Agile Development: Your Step-by-Step Guide
Learn the Basics of Agile Development: Your Step-by-Step Guide
Marcel David
 
Image processinglab image processing image processing
Image processinglab image processing  image processingImage processinglab image processing  image processing
Image processinglab image processing image processing
RaghadHany
 
"Rebranding for Growth", Anna Velykoivanenko
"Rebranding for Growth", Anna Velykoivanenko"Rebranding for Growth", Anna Velykoivanenko
"Rebranding for Growth", Anna Velykoivanenko
Fwdays
 
Electronic_Mail_Attacks-1-35.pdf by xploit
Electronic_Mail_Attacks-1-35.pdf by xploitElectronic_Mail_Attacks-1-35.pdf by xploit
Electronic_Mail_Attacks-1-35.pdf by xploit
niftliyevhuseyn
 
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes
 
Semantic Cultivators : The Critical Future Role to Enable AI
Semantic Cultivators : The Critical Future Role to Enable AISemantic Cultivators : The Critical Future Role to Enable AI
Semantic Cultivators : The Critical Future Role to Enable AI
artmondano
 
Leading AI Innovation As A Product Manager - Michael Jidael
Leading AI Innovation As A Product Manager - Michael JidaelLeading AI Innovation As A Product Manager - Michael Jidael
Leading AI Innovation As A Product Manager - Michael Jidael
Michael Jidael
 
Technology Trends in 2025: AI and Big Data Analytics
Technology Trends in 2025: AI and Big Data AnalyticsTechnology Trends in 2025: AI and Big Data Analytics
Technology Trends in 2025: AI and Big Data Analytics
InData Labs
 
How Can I use the AI Hype in my Business Context?
How Can I use the AI Hype in my Business Context?How Can I use the AI Hype in my Business Context?
How Can I use the AI Hype in my Business Context?
Daniel Lehner
 
"PHP and MySQL CRUD Operations for Student Management System"
"PHP and MySQL CRUD Operations for Student Management System""PHP and MySQL CRUD Operations for Student Management System"
"PHP and MySQL CRUD Operations for Student Management System"
Jainul Musani
 
Buckeye Dreamin 2024: Assessing and Resolving Technical Debt
Buckeye Dreamin 2024: Assessing and Resolving Technical DebtBuckeye Dreamin 2024: Assessing and Resolving Technical Debt
Buckeye Dreamin 2024: Assessing and Resolving Technical Debt
Lynda Kane
 
Automation Dreamin': Capture User Feedback From Anywhere
Automation Dreamin': Capture User Feedback From AnywhereAutomation Dreamin': Capture User Feedback From Anywhere
Automation Dreamin': Capture User Feedback From Anywhere
Lynda Kane
 
AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...
AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...
AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...
SOFTTECHHUB
 
2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx
Samuele Fogagnolo
 
Linux Professional Institute LPIC-1 Exam.pdf
Linux Professional Institute LPIC-1 Exam.pdfLinux Professional Institute LPIC-1 Exam.pdf
Linux Professional Institute LPIC-1 Exam.pdf
RHCSA Guru
 
Build Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For DevsBuild Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For Devs
Brian McKeiver
 
AI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global TrendsAI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global Trends
InData Labs
 
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath MaestroDev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
UiPathCommunity
 
tecnologias de las primeras civilizaciones.pdf
tecnologias de las primeras civilizaciones.pdftecnologias de las primeras civilizaciones.pdf
tecnologias de las primeras civilizaciones.pdf
fjgm517
 
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdfThe Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
Abi john
 
Learn the Basics of Agile Development: Your Step-by-Step Guide
Learn the Basics of Agile Development: Your Step-by-Step GuideLearn the Basics of Agile Development: Your Step-by-Step Guide
Learn the Basics of Agile Development: Your Step-by-Step Guide
Marcel David
 
Image processinglab image processing image processing
Image processinglab image processing  image processingImage processinglab image processing  image processing
Image processinglab image processing image processing
RaghadHany
 
"Rebranding for Growth", Anna Velykoivanenko
"Rebranding for Growth", Anna Velykoivanenko"Rebranding for Growth", Anna Velykoivanenko
"Rebranding for Growth", Anna Velykoivanenko
Fwdays
 
Electronic_Mail_Attacks-1-35.pdf by xploit
Electronic_Mail_Attacks-1-35.pdf by xploitElectronic_Mail_Attacks-1-35.pdf by xploit
Electronic_Mail_Attacks-1-35.pdf by xploit
niftliyevhuseyn
 
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes
 
Semantic Cultivators : The Critical Future Role to Enable AI
Semantic Cultivators : The Critical Future Role to Enable AISemantic Cultivators : The Critical Future Role to Enable AI
Semantic Cultivators : The Critical Future Role to Enable AI
artmondano
 

How to use git without rage

  • 1. Xx de enero de 2010 Use git without rage
  • 2. “VCS should be a subject in informatics” Heared about VCS
  • 3. “ We use VCS as if we were trained monkeys” Heared about VCS
  • 4. Types of VCS LVCS (Localized VCS) CVCS (Centralized VCS) DVCS (Distributed VCS)
  • 5. LVCS cp -r project projectB
  • 8. CVS
  • 12. First-time git setup Three places System: git config --system (/etc/gitconfig)
  • 13. Global: git config --global (~/.gitconfig)
  • 14. Local: git config (cwd) git config [--system | --local] property value
  • 15. git config --global user.name 'wadus'
  • 17. File status cycle untracked staged modified unmodified git add edit git add git commit git commit -a
  • 18. Workflows Scenario 1: Creating a repository from the beginnig and working with it (with no rage)
  • 19. Scenario 1: creating the repository git init (from directory project) Pffffff... this was hard!!!!
  • 20. Workflows -Scenario 1: edit some files Edit and/or create some files for your project this is what developing is about in last term, isn't it?
  • 21. Workflows -Scenario 1: commiting changes So, now you want to commit changes, but first... some advices for those who are used to working with CSCVs such as svn or cvs 100.times do puts “I will think in local terms, 'cos I am not working with remotes (yet)” end
  • 22. Workflows - Scenario 1: adding files to the staging area git status git add <file> -> add files to staging area (either new or modified files) Wow!!! I could not have imagined it!!!!
  • 23. Workflows – Scenario 1: Removing files from the staging area Damn it!!! I staged some files I didn't have to git reset HEAD <file> Phewwww!!!!
  • 24. Workflows – Scenario 1: What am I about to commit? Ok, I want to commit my changes, but which files I am about to commit? git status git diff (for unstaged files) git diff --cached (for staged files)
  • 25. Workflows – Scenario 1: Let's commit!!! git commit -> it will commit all the files in staging area git commit <filename> -> it will commit named files git commit -a -> it will commit all modified files skipping the staging area for those which are not staged
  • 26. Workflows – Scenario 1: deleting files rm <filename> removes file manually git rm <filename> stages deletion ...or... git rm <filename> will do both things
  • 27. Workflows – Scenario 1: undeleting files git status will give you clues if deletion is in the staging area git reset HEAD <filename> if deletion is not in the staging area git checkout <filename>
  • 28. Workflows – Scenario 1: moving files mv filename filename2 git rm filename git add filename2 ...or... git mv filename filename2
  • 29. Workfows- Scenario 1: undoing things git commit --amend will modify last commit git commit “ OMG, WTF, damn it!!! I forgot to add a file” git add damned_file git commit --ammend “ commit --amend FTW!!!”
  • 30. Workfows- Scenario 1: undoing things (ii) Unstaging a staged file git reset HEAD filename Unmodify a modified and unstaged file git checkout filename
  • 31. Workflows Scenario 2: working with remotes
  • 32. Workfows- Scenario 2: adding a remote So I want to work with another repo... git remote add [shortname] [url] git remote add origin your_url Now I finally understand what I've been doing with github all this time!!!
  • 33. Workfows- Scenario 2: showing your remotes If you want to know which repos you are working with: git remote git remote -v
  • 34. Workfows- Scenario 2: fetching and pulling To get data from your remotes git fetch [remote-name] git pull [remote-name] fetch or pull??? pull = fetch + merge
  • 35. Workfows- Scenario 2: pushing If you want to share your data: git push [remote-name] [branch]
  • 36. Workfows- Scenario 2: inspecting a remote git remote show [remote-name] Look at the “Local ref configured for git push” Local refs configured for 'git push': master pushes to master (local out of date) test pushes to test (up to date)
  • 37. Workfows- Scenario 2: removing and renaming remotes git remote rename [original-name] [new-name] git remote rm [remote-name] This changes take effect on your LOCAL repo (remember: local, local, local)
  • 39. Workfows- Scenario 3: listing tags git tag
  • 40. Workfows- Scenario 3: tag types 2 types of tags: lightweight and annotated Lightweight: It is like a branch that doesn't change, a pointer to a specific commit Annotated: These are stored as full objects. Checksumed and metadata are included
  • 41. Workfows- Scenario 3: Creating and showing tags Annotated: git tag -a [tag] Lightweight: git tag [tag] git show [tag]
  • 42. Workfows- Scenario 3: Creating tags later git tag -a <tag> <(part of) checksum of the commit>
  • 43. Workfows- Scenario 3: Sharing tags When pushing, you do not share tags git push origin [tagname] Hey! This is like sharing branches... git push origin --tags shares all the tags
  • 44. Branching: the beginning of magic Please, keep on thinking in local... or I will send @pacoguzman to kill you!!!
  • 45. Branching: the beginning of magic Let's do some review... git add README test.rb LICENSE git commit -m 'initial commit of my project' How is this commit stored?
  • 46. Branching: the beginning of magic taken from http://progit.org/
  • 47. Branching: the beginning of magic Let's assume we keep on doing some commits
  • 48. Branching: the beginning of magic taken from http://progit.org/
  • 49. Branching: the beginning of magic I thought we were going to talk about branches, you son of the bit!!!
  • 50. Branching: the beginning of magic I thought we were going to talk about branches, you son of the bit !!! A very bad geek joke
  • 51. Branching: the beginning of magic Branch: A movable pointer to one of these commits. Do you smell it??? Yeah! And it seems that it's going to taste even better!
  • 52. Branching: the beginning of magic taken from http://progit.org/
  • 53. Branching: the beginning of magic So... let's imagine we want to make a new branch: git branch testing
  • 54. Branching: the beginning of magic taken from http://progit.org/
  • 55. Branching: the beginning of magic Hey! But somehow I have to know wich branch I am at, aren't I???
  • 56. Branching: the beginning of magic taken from http://progit.org/
  • 57. Branching: the beginning of magic git checkout testing
  • 58. Branching: the beginning of magic taken from http://progit.org/
  • 59. Branching: the beginning of magic Very pretty... but... how the hell is this supposed to be useful???
  • 60. Branching: the beginning of magic touch newfile.txt git commit -a -m 'new file'
  • 61. Branching: the beginning of magic taken from http://progit.org/
  • 62. Branching: the beginning of magic git checkout master
  • 63. Branching: the beginning of magic taken from http://progit.org/
  • 64. Branching: the beginning of magic touch another_file.txt git commit -a -m 'another new file in master branch'
  • 65. Branching: the beginning of magic taken from http://progit.org/
  • 66. Workflows Scenario 4: working with branches
  • 67. Scenario 4: Context You are working on a new story, comfortably and peacefully when suddenly you receive a call – OMG! and you are told that it is urgent - but surely not important - to fix some bug in the application (e.g: to change some text which only appears in that last screen of your app)
  • 68. Scenario 4: steps resume Create a branch for the new story you are going to work on
  • 69. Do some work on that branch
  • 70. Swear after you receive that f*ck*ng damned call
  • 71. Commit or stash all the changes that you haven't saved yet – if you want to -
  • 72. Checkout your production (usually master) branch
  • 73. Create a branch to add the hotfix
  • 74. Fix that so f*ck*ng urgent issue
  • 75. Merge this branch and push it to production
  • 76. Switch back to your original story and continue working on it
  • 77. Scenario 4: the process git checkout master -b issue_1 C1 C3 C2 master * issue_1
  • 78. Scenario 4: the process make some changes and commit them C1 C3 C2 master * issue_1 C4
  • 79. Scenario 4: the process Create a new branch from master for that hotfix git checkout master -b hotfix C1 C3 C2 master issue_1 C4 * hotfix
  • 80. Scenario 4: the process Fix the problem and commit changes C1 C3 C2 master issue_1 C4 * hotfix C5
  • 81. Scenario 4: fast forward merge Merge hotfix into master git checkout master git merge hotfix C1 C3 C2 * master issue_1 C4 hotfix C5
  • 82. Scenario 4: fast forward merge What kind of merge is this!!! You have done nothing but moving forward master pointer C1 C3 C2 * master issue_1 C4 hotfix C5
  • 83. Scenario 4: the process End issue_1 and commit changes C1 C3 C2 * master issue_1 C4 hotfix C5 C6
  • 84. Scenario 4: three way merge Merge changes git checkout master git merge issue_1 C3 issue_1 C4 hotfix C5 C6 * master
  • 85. Scenario 4: three way merge Merge changes git checkout master git merge issue_1 C3 * master issue_1 C4 hotfix C5 C6 C7
  • 86. Scenario 4: merge conflicts If there are merge conflicts you have to solve them manually. Once you have resolved them, you can set these files as merged with git add <filename> git commit
  • 87. Scenario 4: branch management git branch lists branches git branch -v lists branches with their last commit git branch --merged lists merged branches git branch --no-merged lists unmerged branches git branch -d <branchname> deletes merged branch (-D for unmerged branches)
  • 89. Branching workflows: long running branches taken from http://progit.org/
  • 90. Branching workflows: topic branches taken from http://progit.org/
  • 91. Branching workflows: topic branches Merge iss91v2 and dumbidea taken from http://progit.org/
  • 92. Remote branches References to the state of branches on your remote repos They are local branches which you can not move. They are moved automatically whenever you do any network communication
  • 93. Pushing branches git push <remote> <branch> [:server_branch_name] git push origin my_local_branch:server_branch
  • 94. Deleting remote branches git push origin :branch_to_be_deleted It's like git push origin (nothing):branch_to_be_deleted
  • 95. Tracking branches Checking out a remote branch, will create a tracking branch. With tracking branches you can call git push git pull without remote or branches names When you clone a repo, a local branch “master” is created, which tracks origin/master
  • 97. Basic rebasing vs merge This is what we already know git merge experiment taken from http://progit.org/
  • 98. Basic rebasing vs merge And this is rebasing git rebase master experiment or... git checkout experiment git rebase master
  • 99. Basic rebasing vs merge taken from http://progit.org/
  • 100. Basic rebasing vs merge It gets the diffs introduced by each commit of the branch you're on. It saves those diffs to temporary files It resets the current branch to the common ancestor with the branch you are rebasing onto It applies these changes and creates a new commit
  • 101. Basic rebasing vs merge Now, you can do a fast forward merge taken from http://progit.org/
  • 102. Rebasing onto other branches taken from http://progit.org/
  • 103. Rebasing onto other branches git rebase --onto master server client taken from http://progit.org/
  • 104. Rebasing onto other branches git checkout master git merge client taken from http://progit.org/
  • 105. Rebasing onto other branches git rebase master server taken from http://progit.org/
  • 106. Rebasing or not rebasing? Be very careful when rebasing commits published in a public repository... …you could be killed by other developers
  • 107. Rebasing or not rebasing? taken from http://progit.org/
  • 108. Rebasing or not rebasing? Fetch changes in remote repo taken from http://progit.org/
  • 109. Rebasing or not rebasing? Someone rebased changes (C4 – C6) taken from http://progit.org/
  • 110. Rebasing or not rebasing? C4 and C4' introduce the same changes taken from http://progit.org/
  • 112. Centralized workflow (small teams) taken from http://progit.org/
  • 113. Integration manager workflow (github) taken from http://progit.org/
  • 114. Dictator Lieutenant Workflow (linux kernel) taken from http://progit.org/
  • 116. Stashing If you're working on some feature and suddenly you are forced to work on a hotfix, what do you do with changes in code you don't want to commit? The answer is Stash
  • 117. Stashing (i) git stash [save 'message'] saves changes Note: if you have untracked files, these won't be stashed git stash list
  • 118. Stashing (ii) git stash apply [stash_id] applies stash git stash drop [stash_id] deletes stash git stash pop [stash_id] applies + deletes git stash show [stash_id] -p|git apply -R unapplies (careful with new files) git stash [stash_id] branch branchname applies into new branch
  • 119. Rewriting history Changing the last commit git commit --ammend Changing history git rebase -i \ <parent_of_the_last_commit_you_want_to_edit> e.g git rebase -i HEAD~3 e.g git rebase my-tag~1
  • 120. Rewriting history: actions pick: use commit normally reword: use commit but edit commit message edit: use commit but stop for amending squash: use commit but meld into previous one fixup: like squash, but discard this commit's log message
  • 121. Cherry picking If you want to get one commit out of a branch git cherry-pick <sha-1_commit> (from the branch which you want the commit into) Be careful because it ends with two different commits which introuduces the same set of changes
  • 122. Getting file's content of a specific revision git show <treeish>:<filename> with this you get the content of that file
  • 123. Debugging with git: file anotation git blame [-L line1, line2] <file> you can see when each line of the method was edited and by whom
  • 124. Debugging with git: binary search git bisect start git bisect bad [commit_id] git bisect good [commit_id] git bisect reset