Introduction

Introduction (简介)

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

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

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

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

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

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.



请遵守《互联网环境法规》文明发言,欢迎讨论问题
扫码反馈

扫一扫,反馈当前页面

咨询反馈
扫码关注
返回顶部