Cloud and DevOps · Chapter 5
Git: fixing mistakes and sharing work
About this chapter
Everyday Git is mostly about undoing and sharing: a conflict halfway through a rebase, a commit that is missing a file, a bad change that has already been pushed. This chapter covers the commands that fix those, how reset, revert and restore differ, tracking down the commit that introduced a bug, setting work aside, tags, how teams use branches, why fetch is not pull, and the reflog that records where everything was.
Who it is for: Developers who commit and merge daily but hesitate over rebasing, resetting or recovering work, and want to answer Git questions in interviews with confidence.
You will be able to
- Resolve a conflict in the middle of a rebase and say which side is which.
- Choose between reset, revert and restore for a given mistake, and explain what each leaves behind.
- Use amend, cherry-pick and interactive rebase to tidy a branch before sharing it.
- Use bisect to locate the change that made a check fail, and stash to set unfinished work aside.
- Explain why fetch is not the same as pull, and how the reflog can bring back a commit that seems lost.
The key idea: Git rarely destroys committed work; it moves names around. Once commits are understood as snapshots and branches as labels, an undo becomes a question of where a label should point, and the reflog remembers where it used to.
In this chapter
- The everyday toolkit
- Resolving a rebase conflict
- Interactive rebase: squash, reword, reorder
- Cherry-picking commits
- Fixing the last commit with amend
- Reset, revert and restore: three different undos
- Finding the commit that broke something
- Stashing work in progress
- Common branching workflows
- Tags and releases
- Remotes: fetch is not pull
- The reflog: Git's undo history
- A checklist across chapters 4, 5 and 8
- Mistakes that recur
Locked: needs a plan
You can read chapter 1 free. Chapter 5 is the next one.
What you can do now, free: re-read chapter 1 and try its problems.
What a plan gives you: all chapters of the track you pick and their checks. Professional, one role is ₹329 a month or ₹2,299 a year. It renews until you cancel, and you can cancel any time. Paid plans open at launch.
Why is this locked?
Chapter 1 of every track is free, so you can see how the track reads. The rest of a track and its checks come with a plan, or open as you pass each chapter's check.
The price is for one period, a month or a year. A plan renews until you cancel.