0
BEING DANGEROUS WITH
GIT

BY YOUR GEEK FRIEND:
/
WHO IS THIS DUDE?
PHP, C, Go - programming language fanatic
open-source geek, Arch linux, DWM, ViM user
Author of
And I sh...
WHY YOU SHOULD CONSIDER USING
GIT
git is decentralized
git is small and fast
git does not store changes - it stores snapsh...
WORKFLOW
Git does not force any workflow, use what works best for
your team and project, even if you are working alone, gi...
WHAT MAY BE USEFUL TO KNOW
ABOUT GIT REPOSITORY
Here is a fresh repository
$l
s
HA
ED
bace
rnhs
cni
ofg
dsrpin
ecito
hos
o...
WHEN TO USE REBASE OR MERGE
Use

to cleanup, prepare and keep up to date your
topic branches.
rebased topic branches or ho...
HOW TO PREVENT THIS FROM
HAPPENING?
gtlg-pet=nln -abe-omt
i o -rtyoeie -brvcmi

rebase your feature branches
EXAMPLE:
mdr~poet& c ~poet
ki /rjc & d /rjc
gtii
i nt
tuhLCNE
oc IES
gtadLCNE
i d IES
gtcmi -m'nta cmi -stlcne
i omt a iii...
LETS REBASE
Interactively rebase 5 commits from HEAD
gtrbs -itrcieHA~
i eae -neatv ED5
At this point we can choose what to do with commits.
Rebase will rewind the chosen number of commits and
modify them accor...
Initially rebase will stop to rename the first commit, we
rename it properly:

Next, rebase will stop on "boostrap project...
Now if we had pushed our commits to git repository in any
branch name, we could reference these commits with their
hashes....
Finally, it will stop to rename "add feature x" commit, it is not
clear what feature we have added, lets fix it as well:

...
And instead of...

We have:

Which history log do you choose to see in production?
Before merging it back to master - make sure you are up to
date
gtfth
i ec
gtrbs oii/atr
i eae rgnmse
There are cases, when you may want to split a commit,
consider a situation:

So what we should do ? gtrbs - HA~
i eae i ED...
Set

for commit, which we want to split

Rebase will rewind, pick the commit for edit and pause. Now
lets reset one commit...
Lets see what we have in
gtsau
i tts

:
Add the first commit, which includes doctrine2 orm. We will
use
so we stage only a specific change.
gtad-pthcmoe.sn
i d -a...
Hit to edit hunk

Now save and close it. We should have only needed changes
staged.
gtcmi - 'nld dcrn2omit poet
i omt m ic...
Next, we have a front controller integration:
gtadscMApFototolrpppbi/
i d r/yp/rnCnrle.h ulc*
gtcmi - 'raefotcnrle'
i omt ...
Hit to edit hunk

Now save and close it. We should have only needed changes
staged.
gtcmi - 'otta ppnttss
i omt m bosrp hu...
And finally we have only behat stuff left.
gtadfaue cmoe.sn
i d etrs opsrjo
gtcmi - 'otta bhtmn fntoa tss
i omt m bosrp ea...
Have fun and be hardcore! And ...

Do not be afraid of rebase, experiment on your branches,
keep branch backups if needed.
THANK YOU
powered by:
Upcoming SlideShare
Loading in...5
×

Being dangerous with git

573

Published on

Slides are about git interactive rebase and how to use it to prepare your branches before merging into main stream.

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
573
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
2
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Transcript of "Being dangerous with git"

  1. 1. BEING DANGEROUS WITH GIT BY YOUR GEEK FRIEND: /
  2. 2. WHO IS THIS DUDE? PHP, C, Go - programming language fanatic open-source geek, Arch linux, DWM, ViM user Author of And I share my stuff
  3. 3. WHY YOU SHOULD CONSIDER USING GIT git is decentralized git is small and fast git does not store changes - it stores snapshots git has a staging area git is a new standard?
  4. 4. WORKFLOW Git does not force any workflow, use what works best for your team and project, even if you are working alone, git will fit perfectly well.
  5. 5. WHAT MAY BE USEFUL TO KNOW ABOUT GIT REPOSITORY Here is a fresh repository $l s HA ED bace rnhs cni ofg dsrpin ecito hos ok idx ne if no ojcs bet rf es guts:
  6. 6. WHEN TO USE REBASE OR MERGE Use to cleanup, prepare and keep up to date your topic branches. rebased topic branches or hotfixes
  7. 7. HOW TO PREVENT THIS FROM HAPPENING? gtlg-pet=nln -abe-omt i o -rtyoeie -brvcmi rebase your feature branches
  8. 8. EXAMPLE: mdr~poet& c ~poet ki /rjc & d /rjc gtii i nt tuhLCNE oc IES gtadLCNE i d IES gtcmi -m'nta cmi -stlcne i omt a iiil omt e ies' gtrmt adoii hts/gtu.o/srpoetgt i eoe d rgn tp:/ihbcmue/rjc.i gtceku - fauepoetbosrp i hcot b etr/rjc-otta After a while... Do you want this to go into production stream?
  9. 9. LETS REBASE Interactively rebase 5 commits from HEAD gtrbs -itrcieHA~ i eae -neatv ED5
  10. 10. At this point we can choose what to do with commits. Rebase will rewind the chosen number of commits and modify them accordingly to prefered changes.
  11. 11. Initially rebase will stop to rename the first commit, we rename it properly: Next, rebase will stop on "boostrap project" wich will have two commits squashed
  12. 12. Now if we had pushed our commits to git repository in any branch name, we could reference these commits with their hashes. This way it could look like: Since we haven't, we can just leave those as extra commit messages
  13. 13. Finally, it will stop to rename "add feature x" commit, it is not clear what feature we have added, lets fix it as well: When we save and close it, rebase will finish
  14. 14. And instead of... We have: Which history log do you choose to see in production?
  15. 15. Before merging it back to master - make sure you are up to date gtfth i ec gtrbs oii/atr i eae rgnmse
  16. 16. There are cases, when you may want to split a commit, consider a situation: So what we should do ? gtrbs - HA~ i eae i ED4
  17. 17. Set for commit, which we want to split Rebase will rewind, pick the commit for edit and pause. Now lets reset one commit from the current HEAD gtrstHA~ i ee ED
  18. 18. Lets see what we have in gtsau i tts :
  19. 19. Add the first commit, which includes doctrine2 orm. We will use so we stage only a specific change. gtad-pthcmoe.sn i d -ac opsrjo
  20. 20. Hit to edit hunk Now save and close it. We should have only needed changes staged. gtcmi - 'nld dcrn2omit poet i omt m icue otie r no rjc'
  21. 21. Next, we have a front controller integration: gtadscMApFototolrpppbi/ i d r/yp/rnCnrle.h ulc* gtcmi - 'raefotcnrle' i omt m cet rn otolr Further more, lets commit phpunit gtadppntxlds tss i d hui.m.it et And again patch a composer.json change: gtad- cmoe.sn i d p opsrjo
  22. 22. Hit to edit hunk Now save and close it. We should have only needed changes staged. gtcmi - 'otta ppnttss i omt m bosrp hui et'
  23. 23. And finally we have only behat stuff left. gtadfaue cmoe.sn i d etrs opsrjo gtcmi - 'otta bhtmn fntoa tss i omt m bosrp ea ik ucinl et' gtrbs -cniu i eae -otne Thats it! Now we have:
  24. 24. Have fun and be hardcore! And ... Do not be afraid of rebase, experiment on your branches, keep branch backups if needed.
  25. 25. THANK YOU powered by:
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×