Решение 1 — Создание и разрешение merge-конфликта
Полный сценарий из лекции:
# Шаг 1: Инициализация
mkdir git-merge-test
cd git-merge-test
git init .
echo "this is some content to mess with" > merge.txt
git add merge.txt
git commit -am "we are commiting the inital content"
# Шаг 2: Ветка с конфликтом
git checkout -b new_branch_to_merge_later
echo "totally different content to merge later" > merge.txt
git commit -am "edited the content of merge.txt to cause a conflict"
# Шаг 3: Изменить main тоже
git checkout main
echo "content to append" >> merge.txt
git commit -am "appended content to merge.txt"
# Шаг 4: Merge → CONFLICT
git merge new_branch_to_merge_later
# CONFLICT (content): Merge conflict in merge.txt
# Шаг 5: Диагностика
git status # показывает: both modified: merge.txt
git log --merge # коммиты конфликтующих веток
# Шаг 6: Посмотреть содержимое файла
cat merge.txt
# <<<<<<< HEAD
# this is some content to mess with
# content to append
# =======
# totally different content to merge later
# >>>>>>> new_branch_to_merge_later
# Шаг 7: Разрешить вручную — отредактировать файл:
# Удалить маркеры, оставить нужный код:
# this is some content to mess with
# content to append
# Шаг 8: Завершить слияние
git add merge.txt
git merge --continue
# [main e4f5c6a] Merge branch 'new_branch_to_merge_later'
Решение 2 — Миграция в monorepo
# Создать директорию для monorepo
mkdir ~/linux-git-monorepo
cd ~/linux-git-monorepo
git init
# Скопировать репозитории (структура по вашему усмотрению)
mkdir -p bash-lessons git-lessons
cp -r ~/Lesson1 bash-lessons/lesson01
cp -r ~/Lesson2 bash-lessons/lesson02
cp -r ~/Lesson3 git-lessons/lesson03
# Проверить что будет удалено (ОБЯЗАТЕЛЬНО перед удалением)
find . -type d -name ".git" -not -path "./.git"
# Вывод: ./bash-lessons/lesson01/.git
# ./bash-lessons/lesson02/.git
# ./git-lessons/lesson03/.git
# Удалить .git в поддиректориях (теряем историю!)
find . -type d -name ".git" -exec rm -rf {} +
# Добавить всё в monorepo
git add .
git commit -m "Initial monorepo: migrate lessons 1-3"
# Добавить удалённый репозиторий и запушить
git remote add origin https://github.com/user/linux-git-monorepo.git
git push -u origin main