Book Image

Git for Programmers

By : Jesse Liberty
Book Image

Git for Programmers

By: Jesse Liberty

Overview of this book

Whether you’re looking for a book to deepen your understanding of Git or a refresher, this book is the ultimate guide to Git. Git for Programmers comprehensively equips you with actionable insights on advanced Git concepts in an engaging and straightforward way. As you progress through the chapters, you’ll gain expertise (and confidence) on Git with lots of practical use cases. After a quick refresher on git history and installation, you’ll dive straight into the creation and cloning of your repository. You’ll explore Git places, branching, and GUIs to get familiar with the fundamentals. Then you’ll learn how to handle merge conflicts, rebase, amend, interactive rebase, and use the log, as well as explore important Git commands for managing your repository. The troubleshooting part of this Git book will include detailed instructions on how to bisect, blame, and several other problem handling techniques that will complete your newly acquired Git arsenal. By the end of this book, you’ll be using Git with confidence. Saving, sharing, managing files as well as undoing mistakes and basically rewriting history will be a breeze.
Table of Contents (16 chapters)
11
Finding a Broken Commit: Bisect and Blame
13
Next Steps
14
Other Books You May Enjoy
15
Index

Standard workflow

The standard workflow is pretty much what we've seen in the previous five chapters, except that you usually would not commit so quickly or often. Typically, it goes like this:

  1. Create a repository.
  2. Either clone that repository from the server, or if it was created locally, push it to the server.
  3. Create a branch.
  4. Code.
  5. Test.
  6. Commit.
  7. Repeat steps 4-6 until you have a block of code that does "something" (e.g. opens a dialog box and processes the result).
  8. Test.
  9. Commit.
  10. Push.
  11. Repeat steps 4-10 until you have fulfilled a requirement (self-imposed or otherwise).
  12. Merge into the main branch (or create a pull request if you are in a team).

There are variants on this. Some people like to push after each commit, but that prevents them from using interactive rebase to reorganize their commits. What happens though if you have pushed your commit and realize that there is additional...