Presentation is loading. Please wait.

Presentation is loading. Please wait.

Thanks to our Sponsors! Community Sponsor Yearly Sponsor Marquee Sponsor.

Similar presentations


Presentation on theme: "Thanks to our Sponsors! Community Sponsor Yearly Sponsor Marquee Sponsor."— Presentation transcript:

1 Thanks to our Sponsors! Community Sponsor Yearly Sponsor Marquee Sponsor

2 Git Merge vs Rebase Utah Code Camp - Spring 2016

3 Who Are You? Josh Jones Game Programmer - Wild Works Chair - IGDA Salt Lake City/Provo Area Chapter ~8 years using git Audience Command Line users? GUI users? (TortoiseGit, SmartGit, etc.) GitHub? BitBucket? Unfuddle?

4 Follow Along? These slides: http://bit.ly/1XpxXWVhttp://bit.ly/1XpxXWV (BIT DOT LY SLASH ONE X p x X W V) Git repo: https://github.com/vazor222/gitMergeVsRebase.git

5 Basic VCS Overview Provide backups or snapshots of code as it is developed so things can easily be reverted. Allow collaboration. Develop in parallel with branches and resolve conflicts later. Simple workflow: Clone/Checkout/Switch/Pull/Update/Sync/Merge - acquire code Modify/Diff/Branch/WorkDir/Repo/Stash - edit code, view changes, store changes Commit/Submit/Patch/ChangeSet/PR - declare your changes to the code base Push/Commit/CopyTo/CopyUp - share code Other amenities (blame, pull requests, line endings, ignore, etc.)

6

7 Git merge vs rebase - high level Merge Preserves the most information (--no-ff) More ugly (cluttered) history Easier to understand Less Fast-Forward merges after integration Pull Reviews are more clear Rebase Preserves less information Cleaner (less cluttered) history Requires learning rebase More clean merges after integration Can confuse Pull Reviews

8

9 Git Merge Used to integrate two branches together. Creates a Merge Commit unless merge is Fast Forwarded. Local vs Remote branches. May result in conflicts- automatically highlighted in merge commit. Straightforward concept. Ultimately necessary for collaboration on the same code base with branches.

10 Git Merge Example Command Line git clone https://github.com/vazor222/gitMergeVsRebase.git git checkout -b featureToMerge1 (make changes) git commit -a -m "worked on my feature 1" git checkout master (make changes) git commit -a -m "master my update 1" git merge featureToMerge1 (normally pull) git log --pretty --graph (note the merge commit) https://github.com/vazor222/gitMergeVsRebase.git TortoiseGit Right-click in workspace, clone: https://github.com/vazor222/gitMergeVsRebase.git Switch/Checkout... leave top option as master, check create branch box: featureToMerge2 (make changes) Commit to: featureToMerge2 Switch/Checkout... choose: master (make changes) Commit to: master (make sure master is sync'd) Merge... choose branch: featureToMerge2 Show log https://github.com/vazor222/gitMergeVsRebase.git

11

12 Git Rebase Used to change where a branch is "based" - where it applies its changes and commits. Time travel - can change history! Generally requires you to force push after. Upstream, Branch, and Newbase (-onto). Skips identical commits by default. Handling merge conflicts (-abort, -continue, and -skip). Similar commands and flags such as squash and --amend may be useful. An immensely deep and versatile command.

13 Do NOT force push to shared branches!

14 Git Rebase Example git branch featureToRebase1 (on master, make changes) git commit -a -m "master my update 2" git checkout featureToRebase1 (make changes) git commit -a -m "worked on my feature 2" git rebase master ( sync first, master is the upstream ) (resolve conflicts, git add, git rebase --continue) (force push to your remote branch for PR) git checkout master (make sure master is synced) git merge featureToRebase1 git log --pretty --graph (if fast-forward, note the lack of merge commit) Create Branch... featureToRebase2 (don't switch) (on master, make changes) Commit to: master Switch/Checkout... choose: featureToRebase2 (make changes) Commit to: featureToRebase2 (you might have to click all branches in log here) Rebase... choose upstream: master, Start Rebase (resolve conflicts if needed until Done) (log should show the commit from master) Switch/Checkout... choose: master Merge... choose branch: featureToRebase2 Show log

15 Git merge vs rebase - high level (again) Merge Preserves the most information (--no-ff) More ugly (cluttered) history Easier to understand Less Fast-Forward merges after integration Pull Reviews are more clear Rebase Preserves less information Cleaner (less cluttered) history Requires learning rebase More clean merges after integration Can confuse Pull Reviews

16

17 Workflows (from general articles online- any workflow can be made with the opposite option) Centralized (single master branch) - prefers rebase Feature Branches (develop and master branches) - prefers merge --no-ff Distributed/Fork Workflows - no preference/mixed Version/Release Branches - prefers merge Topic Branch - prefers rebase Skullcandy Workflow - prefers merge --no-ff

18 Resources / Questions? https://www.atlassian.com/git/tutorials/merging-vs-rebasing/workflow-walkthrough http://endoflineblog.com/gitflow-considered-harmful https://medium.com/@porteneuve/getting-solid-at-git-rebase-vs-merge-4fa1a48c53aa https://git-scm.com/docs/git-rebase Contact: @vazor222 vazor222@gmail.com vazor222@gmail.com These slides: http://bit.ly/1XpxXWV http://bit.ly/1XpxXWV


Download ppt "Thanks to our Sponsors! Community Sponsor Yearly Sponsor Marquee Sponsor."

Similar presentations


Ads by Google