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

Branches

Using branches is critical to working with Git, not to mention to the success of your project. The idea is this: you have a "main" branch that you'll do your releases from. Each time code is added to the main branch it is checked and reviewed so that the main branch stays as clean as possible.

When you want to work on a bug or a feature, you create a new branch (often called a feature branch). This creates a copy of the code that is currently in the main branch. You can work on your feature branch without affecting the main branch at all. Once you are done, and all is working, you can then "merge" your feature branch into the main branch:

Figure 3.11: First feature branch

Notice that there is a pointer named Head. This points to whatever is in your work area. In this case, we've branched to Feature 1 and Head shows that the code for that feature branch is now in our work area.

That is a pretty good simplification of branching...