Merging vs Rebasing, handy efficiencies, understanding workflows, and getting out of a jam
Git is key to many developers’ workflows. Unfortunately, many developers only know enough to get by. Additionally, because Git does not have an obvious mental model or intuitively-named commands, developers often struggle, sometimes badly. Given how powerful Git is - and the tremendous abilities it offers to those who understand - this is sad! To address this, this class will cover merge vs rebase, aliases, major workflows, three uses of rebase, setting up an external editor, and getting out of a jam (reflog, reset, and cherry-pick).
What you'll learn-and how you can apply it
- Learn the differences, advantages, and disadvantages of merge and rebase
- Intelligently converse on why you should choose merge or rebase
- Create and use aliases, if desired
- Differentiate between a few primary workflows and their benefits
- Interactively rebase, i.e. squash commits
- Set up an external editor
- Rebase a local branch onto another local branch
- Update a local branch from a remote branch using rebase
- Move forward, backward, or sideways in time to get out of a jam or just to use Git to its full creative potential
This training course is for you because...
- You can navigate your local repo with ease (git add, git commit, git checkout, etc) but you aren’t so sure about interacting with other repos.
- You want to be able to contribute to discussions on which workflow your team should use and/or how to tweak or improve your current workflow.
- You want to understand merge vs rebase.
- You want to become more efficient, faster.
- You want to become so good at Git that you don’t even think about it anymore; it is after all, only a facilitative element.
- You want to know how to get yourself out of a jam.
- Must know the concept of a repo.
- Must know these basic Git commands: git add, git commit, git checkout, git branch, git fetch, git pull, git push.
- Must be comfortable using Git in command-line interface because we will not be using a graphical user interface.
- Must know a handful of basic command-line interface commands such as “cd”.
Course Set-up: - Course Set-up Instructions - Git should be installed - An IDE should be installed - This course is tailored for those on Macs. If on Windows, the concepts will still apply.
Git Essentials Live Lessons (video)
About your instructor
The timeframes are only estimates and may vary according to how the class is progressing
Segment 1: Overview and Repo Setup (20 min)
- Instructor will describe her personal motivation for learning/conquering these concepts and lay out what the class will cover, and will then help everyone get their repo setup for use during class.
- Participants will (hopefully) be inspired to get into the content and will know the sequence of topics.
Segment 2: Merge (10 min)
- Instructor will present the model model behind merge.
- Participants will understand what’s happening “under the hood” when merging.
Segment 3: Rebase (10 min)
- Instructor will present the model model behind rebase.
- Participants will understand what’s happening “under the hood” when rebasing.
- Exercise: add a few commits, run git merge, run git rebase, compare (10 min)
Segment 4: The Golden Rule of Rebase (5 min)
- Instructor will present the Golden Rule
- Participants will learn a little fear/respect regarding the significance of this rule
Segment 5: Rewriting History (10 min)
- Instructor will present the primary controversy behind rebasing, step through it, put it in perspective, and encourage an entirely different and more healthy/significant perspective.
- Participants will learn lose any concern they had over rewriting history, will lose any moral sense about these things, and will instead recognize that Git is just a tool (not a matter of right and wrong) and recognize the significance of asking the “better question” which is “what story do you want master to tell?”
Break: 10 min
Segment 6: Efficiency: Aliases (5 min)
- Instructor will present what aliases are, their advantages and disadvantages, and how to create them.
- Participants will learn everything they need to know about aliases
- Exercise: add aliases for your most commonly-used commands, whether Git commands or not (5 min)
Segment 7: Major Workflows (10 min)
- Instructor will present the major workflows that teams usually choose from and the fact that, at the end of the day, there are as many workflows as there are minds.
- Participants will learn what a workflow is and how to choose between them.
Segment 8: Three Uses of Rebase: Interactive Rebase + Efficiency: Set up an External Editor (15 min)
- Instructor will present three uses of rebase, the first of which is an interactive rebase. Directly after this, instructor will demo this which will make it very clear why you would want to set up an external editor. This will be followed by setting up an external editor.
- Participants will learn the first of three uses of rebase plus an efficiency, that of setting up an external editor
- Exercise: set up an external editor (15 min)
Break: 10 min
Segment 9: Three Uses of Rebase: Local rebase (5 min)
- Instructor describe/present and demo a local to local rebase.
- Participants will learn the second of three uses of rebase.
- Exercise: local to local rebase (5 min)
Segment 10: Three Uses of Rebase: Remote to local rebase (5 min)
- Instructor describe/present and demo a remote to local rebase.
- Participants will learn the third of three uses of rebase.
- Exercise: remote to local rebase (5 min)
Segment 11: Full Life Cycle Incorporating Rebase (5 min)
- Instructor will present a scenario where two of uses of rebase are used to achieve a particular goal in a given workflow, and will discuss her own daily workflow and use of rebase.
- Participants will observe that rebase and merge can be used together in the same workflow, will learn that multiple uses of rebase can be best, and will hopefully conclude that once a workflow is known it and should be very, very easy and reliable. Exercise: try out all steps just described (10)
Segment 12: How to Get Out of a Jam (5 min)
- Instructor will present how to get out of a jam using reflog, reset, and cherry-pick
- Participants will lose any concern over losing committed work, will gain confidence in Git and will hopefully be encouraged to try out more things in their code knowing “Git has their back”, and will learn how to get out of a jam
- Exercise: use git reflog, reset, and cherry-pick to move around in time in your repo (5 min)