mergeconflicts

Branching allows developers to branch out from the original code base and work separately. This section of the book will teach you the basics of creating, switching, merging and deleting branches. It will also provide tools to solve merge conflicts and multiple strategies to choose while merging. Here are the commands that will help you accomplish your work. Read more information about the following commands on the next pages.

git branch

The git branch command creates, lists, and deletes branches. It doesn’t allow switching between branches or putting a forked history back together again. Creating a new branch points out the commit not changes the repository. The git branch is integrated with the git checkout and git merge commands. Git branches are a pointer to a snapshot of the changes you have made.

git checkout

The git checkout command switches branches or restores working tree files. It operates on files, commits, and branches. It also allows switching between multiple features in just a single repository. The git checkout command updates the files in the working directory to match the version stored in that branch telling Git to record all the new commits.

git merge

The git merge command integrates the independent lines of development into a single branch. The git merge command goes hand in hand with the git checkout command to select the current branch and the git branch command with the -d flag to delete the obsolete target branch. The basic use of git merge is to combine two branches but it also used to merge multiple commits into one history.

merge conflicts

The git merge command is responsible for combining isolated branches and resolving conflicting edits. Merge conflicts occur when multiple authors edit the same content or when one developer deletes a file while another developer was making changes on it. To solve this problem developers work in isolated branches.

git merge strategies

When the work is complete and ready to be merged into the main line of the development, a merge strategy should be chosen. If the strategy is not specified, the git merge command will automatically select a merge strategy based on the provided branches.

Practice Your Knowledge

What are the functionalities of different Git commands related to branching?

Quiz Time: Test Your Skills!

Ready to challenge what you've learned? Dive into our interactive quizzes for a deeper understanding and a fun way to reinforce your knowledge.

Do you find this helpful?