RUVIDEO
Поделитесь видео 🙏

GitHub tutorial 11: Resolve merge conflicts смотреть онлайн

In tutorial 9 - working on custom branch, I briefly mentioned the merge conflicts without putting too much effort in explaining it. Now we have a dedicated section just for merge conflicts.

Merge conflicts are the differences that cannot be automatically resolved by Git when merging two branches. They are usually caused by two branches editing the same line of the same file, or one file is deleted in one branch, but edited in another. Conflicts most likely happen in a team environment.

There are two types of merge conflicts:

(1) Type one happens before merge can start, which is resulted from that pending changes have not been committed in either branch. Git will show you the message like the files are not up to date. The solution is simple: commit and push the changes to repository.

(2) Type two happens during the merge process, which is caused by either conflicts in the same line of the same file, or the file was deleted in one branch, but was edited in another, as we mentioned before. This is the type of merge conflicts we will focus our effort on. The methods to resolve merge conflicts we are going to learn belong to this type of conflicts.

First, let's look at the method to resolve competing line. The conflict markers contain seven less signs with word HEAD that is the base branch, seven equal signs (=======), and seven greater signs and the compare branch name. Here is an example. The line between less signs and equal signs is from master branch, while the line between equal signs and greater signs is from develop branch.

To resolve this conflict, remove the conflict markers, and manually combine the conflict lines into the final change. Then use Git commands to add the changed file to staging area, commit to local repository, push to remote repository.

Here is a demo to show the whole process.

There are 3 files in the master branch. We will produce merge conflicts using the file "demo-01.txt". There are 3 lines in this file:
- line 1: no conflict
- line 2: demo merge conflicts
- line 3: no conflict

Let's create a branch "develop", and switch to this new branch. List all branches. The active branch is "develop". Before we make any modification, set upstream to this branch. Now modify file "demo-01.txt". Change the text in second line to: from develop branch. Save the change. Check status. Add change to staging area. Commit the change to local repository with comment: modified from develop branch. Write and quit Vim editor. Push to remote repository. Wait till finish.

Switch back to master branch. List the files. Modify the same file "demo-01.txt". You can see that the text in line 2 is the same as in the original file, not from develop branch. We will change it to: from master branch. Save the change. Add the change to staging area. Commit to local repository with comment: modified from master branch. Write and quit Vim editor. Push to remote repository. Wait till finish.

Now when we try to merge the changes from develop branch into master branch. It failed with this message:
Auto-merging demo-01.txt.
CONFLICT (content): Merge conflict in demo-01.txt.
Automatic merge failed; fix conflicts and then commit the result.

This is what we will do. Open demo-01.txt. Remove conflict markers: the line of seven less signs, the line of seven equal signs, the line of seven greater signs. Change line 2 text to: from master and develop branch. Save the file. Add change to staging area. Commit to local repository with comment: fixed merge conflicts. Write and quit Vim editor. Push to remote repository.

Inspect the final merged file: demo-01.txt. The line 2 shows the text as expected: from master and develop branch.

Hopefully now you have a good understanding on how to resolve the merge conflicts due to competing lines in the same file from different branches.

Let's move on to the solution to resolve deletion conflicts. It's relatively simpler to fix this conflict than the previous one. After having decided if the file needs to be kept or deleted, we can use Git commands to add or remove it from staging area, then commit to local repository, push to remote repository.

Let me demo how to accomplish this.

We start with master branch. There are 3 files. Demo-02.txt file will be the one to be deleted in another branch, and modified in master branch.

(refer to video for detail)

In summary, with two live demos, we have learned how to resolve two kinds of merge conflicts:
(1) competing line conflicts
(2) file deletion conflicts
These are the two most common merge conflicts.

Thanks for watching!

Что делает видео по-настоящему запоминающимся? Наверное, та самая атмосфера, которая заставляет забыть о времени. Когда вы заходите на RUVIDEO, чтобы посмотреть онлайн «GitHub tutorial 11: Resolve merge conflicts» бесплатно и без регистрации, вы рассчитываете на нечто большее, чем просто загрузку плеера. И мы это понимаем. Контент такого уровня заслуживает того, чтобы его смотрели в HD 1080, без дрожания картинки и бесконечного буферизации.

Честно говоря, Rutube сегодня — это кладезь уникальных находок, которые часто теряются в общем шуме. Мы же вытаскиваем на поверхность самое интересное. Будь то динамичный экшн, глубокий разбор темы от любимого автора или просто уютное видео для настроения — всё это доступно здесь бесплатно и без лишних формальностей. Никаких «заполните анкету, чтобы продолжить». Только вы, ваш экран и качественный поток.

Если вас зацепило это видео, не забудьте взглянуть на похожие материалы в блоке справа. Мы откалибровали наши алгоритмы так, чтобы они подбирали контент не просто «по тегам», а по настроению и смыслу. Ведь в конечном итоге, онлайн-кинотеатр — это не склад файлов, а место, где каждый вечер можно найти свою историю. Приятного вам отдыха на RUVIDEO!

Видео взято из открытых источников Rutube. Если вы правообладатель, обратитесь к первоисточнику.