Skip to main content
CodeOath

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

  1. The everyday toolkit
  2. Resolving a rebase conflict
  3. Interactive rebase: squash, reword, reorder
  4. Cherry-picking commits
  5. Fixing the last commit with amend
  6. Reset, revert and restore: three different undos
  7. Finding the commit that broke something
  8. Stashing work in progress
  9. Common branching workflows
  10. Tags and releases
  11. Remotes: fetch is not pull
  12. The reflog: Git's undo history
  13. A checklist across chapters 4, 5 and 8
  14. 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.

Back to the track