diff --git a/report.txt b/report.txt new file mode 100644 index 0000000..6a5ad44 --- /dev/null +++ b/report.txt @@ -0,0 +1,843 @@ +Отчет по лабораторной работе № 2 "Система контроля версий Git" + +Выполнил: Мячин П. Е. +Группа: А-01-24 +Проверил: + +Примечание: работа выполнялась на Windows. + +1. Создал на рабочем столе каталог lab02 и запустил в нем Git Bash, приглашение: + +платон@WIN-TE35OG7T01L CLANGARM64 ~/Desktop/lab02 +$ + + +2. Просмотрел файлы в рабочем каталоге можно командой "ls" --- пусто: + +платон@WIN-TE35OG7T01L CLANGARM64 ~/Desktop/lab02 +$ ls + +платон@WIN-TE35OG7T01L CLANGARM64 ~/Desktop/lab02 +$ + + +3. Создал каталоги Алисы и Боба, создал каталог "project", +изучил команду "cd" в процессе: + +платон@WIN-TE35OG7T01L CLANGARM64 ~/Desktop/lab02 +$ mkdir alice + +платон@WIN-TE35OG7T01L CLANGARM64 ~/Desktop/lab02 +$ mkdir bob + +платон@WIN-TE35OG7T01L CLANGARM64 ~/Desktop/lab02 +$ cd bob + +платон@WIN-TE35OG7T01L CLANGARM64 ~/Desktop/lab02/bob +$ cd .. + +ivan@HOME-PC MINGW32 /c/Users/ivan/Desktop/lab02 +$ cd alice + +платон@WIN-TE35OG7T01L CLANGARM64 ~/Desktop/lab02/alice +$ mkdir project + +платон@WIN-TE35OG7T01L CLANGARM64 ~/Desktop/lab02/alice +$ ls +project + +платон@WIN-TE35OG7T01L CLANGARM64 ~/Desktop/lab02/alice +$ cd project + + +4. Инициализировал репозитарий: + +платон@WIN-TE35OG7T01L CLANGARM64 ~/Desktop/lab02/alice/project +$ git init +Initialized empty Git repository in C:/Users/платон/Desktop/lab02/alice/project/.git/ + +поменял имя ветки на main +платон@WIN-TE35OG7T01L CLANGARM64 ~/Desktop/lab02/alice/project (master) +$ git branch -m main + +платон@WIN-TE35OG7T01L CLANGARM64 ~/Desktop/lab02/alice/project (main) +$ + +настройка репозитория алисы: +платон@WIN-TE35OG7T01L CLANGARM64 ~/Desktop/lab02/alice/project (main) +$ git config user.name 'Alice(MiachinPE)' +платон@WIN-TE35OG7T01L CLANGARM64 ~/Desktop/lab02/alice/project (main) +$ git config user.email 'myteddy062@gmail.com' + +проверка состояния: +платон@WIN-TE35OG7T01L CLANGARM64 ~/Desktop/lab02/alice/project (main) +$ git status +On branch main + +No commits yet + +Untracked files: + (use "git add ..." to include in what will be committed) + bin/ + main.cpp + obj/ + project.cbp + +nothing added to commit but untracked files present (use "git add" to track) + +добавление файла: +платон@WIN-TE35OG7T01L CLANGARM64 ~/Desktop/lab02/alice/project (main) +$ git add main.cpp + +после: +платон@WIN-TE35OG7T01L CLANGARM64 ~/Desktop/lab02/alice/project (main) +$ git status +On branch main + +No commits yet + +Changes to be committed: + (use "git rm --cached ..." to unstage) + new file: main.cpp + +Untracked files: + (use "git add ..." to include in what will be committed) + bin/ + obj/ + project.cbp + +коммит: + +платон@WIN-TE35OG7T01L CLANGARM64 ~/Desktop/lab02/alice/project (main) +$ git commit -m 'code: заготовка программы' +[main (root-commit) 89f6ee8] code: заготовка программы + 1 file changed, 9 insertions(+) + create mode 100644 main.cpp + +!!!лаба пошла не по плану и я откатился к этому коммиту + +~алиса~ +платон@WIN-TE35OG7T01L CLANGARM64 ~/Desktop/lab02/alice/project (main) +$ git reset --hard 89f6ee8 +HEAD is now at 89f6ee8 code: заготовка программы + +платон@WIN-TE35OG7T01L CLANGARM64 ~/Desktop/lab02/alice/project (main) +$ git push -f origin main +Total 0 (delta 0), reused 0 (delta 0), pack-reused 0 (from 0) +remote: . Processing 1 references +remote: Processed 1 references in total +To http://uit.mpei.ru/git/MiachinPY/cs-lab02.git + + ebe5fcc...89f6ee8 main -> main (forced update) + +~боб~ + +удаляю папу project + +платон@WIN-TE35OG7T01L CLANGARM64 ~/Desktop/lab02/bob/project (main) +$ git clone http://uit.mpei.ru/git/MiachinPY/cs-lab02 project +Cloning into 'project'... +remote: Enumerating objects: 3, done. +remote: Counting objects: 100% (3/3), done. +remote: Compressing objects: 100% (2/2), done. +remote: Total 3 (delta 0), reused 0 (delta 0), pack-reused 0 +Receiving objects: 100% (3/3), done. + +платон@WIN-TE35OG7T01L CLANGARM64 ~/Desktop/lab02/bob/project (main) +$ cd project + +платон@WIN-TE35OG7T01L CLANGARM64 ~/Desktop/lab02/bob/project/project (main) +$ git config user.name "Bob (MiachinPY)" + +платон@WIN-TE35OG7T01L CLANGARM64 ~/Desktop/lab02/bob/project/project (main) +$ git config user.email "bob@example.com" +!!! + +добавление своего файла и коммит: + +платон@WIN-TE35OG7T01L CLANGARM64 ~/Desktop/lab02/alice/project (main) +$ git add project.cbp +warning: in the working copy of 'project.cbp', LF will be replaced by CRLF the next time Git touches it + +платон@WIN-TE35OG7T01L CLANGARM64 ~/Desktop/lab02/alice/project (main) +$ git commit -m 'build: добавлен файл проекта' +[main 0472419] build: добавлен файл проекта + 1 file changed, 40 insertions(+) + create mode 100644 project.cbp + +платон@WIN-TE35OG7T01L CLANGARM64 ~/Desktop/lab02/alice/project (main) +$ git status +On branch main +Your branch is ahead of 'origin/main' by 1 commit. -- вот тут видно что есть коммит + (use "git push" to publish your local commits) + +Changes not staged for commit: + (use "git add ..." to update what will be committed) + (use "git restore ..." to discard changes in working directory) + modified: main.cpp + +no changes added to commit (use "git add" and/or "git commit -a") + +коммит main и репозиторий после изменения кода main.cpp: +1) +платон@WIN-TE35OG7T01L CLANGARM64 ~/Desktop/lab02/alice/project (main) +$ git add -u + +платон@WIN-TE35OG7T01L CLANGARM64 ~/Desktop/lab02/alice/project (main) +$ git commit -m "добавление суммы и разности(алиса)" +[main 3ed9523] добавление суммы и разности(алиса) + 1 file changed, 5 insertions(+), 2 deletions(-) + +Игнорирование файлов +платон@WIN-TE35OG7T01L CLANGARM64 ~/Desktop/lab02/alice/project (main) +$ echo "/bin/" >> .gitignore + +платон@WIN-TE35OG7T01L CLANGARM64 ~/Desktop/lab02/alice/project (main) +$ echo "/obj/" >> .gitignore + +платон@WIN-TE35OG7T01L CLANGARM64 ~/Desktop/lab02/alice/project (main) +$ echo "*.layout" >> .gitignore + +платон@WIN-TE35OG7T01L CLANGARM64 ~/Desktop/lab02/alice/project (main) +$ cat .gitignore +/bin/ +/obj/ +*.layout + +платон@WIN-TE35OG7T01L CLANGARM64 ~/Desktop/lab02/alice/project (main) +$ git add .gitignore +warning: in the working copy of '.gitignore', LF will be replaced by CRLF the next time Git touches it + +платон@WIN-TE35OG7T01L CLANGARM64 ~/Desktop/lab02/alice/project (main) +$ git commit -m "build: добавлен .gitignore" +[main 727003c] build: добавлен .gitignore + 1 file changed, 3 insertions(+) + create mode 100644 .gitignore + +Работа с журналом репозитария +платон@WIN-TE35OG7T01L CLANGARM64 ~/Desktop/lab02/alice/project (main) +$ git log --stat +commit 727003ccbcf1594b14db8f2e68d212c37f65d1d3 (HEAD -> main) -- хэш +Author: Bob -- автор +Date: Sat Mar 29 20:24:30 2025 +0300 -- дата + + build: добавлен .gitignore -- описание + + .gitignore | 3 +++ -- файл .gitignore был изменен: добавлено 3 строки + 1 file changed, 3 insertions(+) -- 1 файл изменен, 3 строки добавлено + +commit 3ed9523d8c15b577da1c975acd0082a7a7e711be +Author: Bob +Date: Sat Mar 29 20:21:53 2025 +0300 + + добавление суммы и разности(алиса) + + main.cpp | 7 +++++-- + 1 file changed, 5 insertions(+), 2 deletions(-) + +commit 22b96a493326cbcb2faf8eb515887079d68044ef +Author: Bob +Date: Sat Mar 29 20:16:00 2025 +0300 + + build: добавлен файл проекта + + project.cbp | 40 ++++++++++++++++++++++++++++++++++++++++ + 1 file changed, 40 insertions(+) + +Изменения по теме build: + +платон@WIN-TE35OG7T01L CLANGARM64 ~/Desktop/lab02/alice/project (main) +$ git log --grep "build:" +commit 727003ccbcf1594b14db8f2e68d212c37f65d1d3 (HEAD -> main) +Author: Bob +Date: Sat Mar 29 20:24:30 2025 +0300 + + build: добавлен .gitignore + +commit 22b96a493326cbcb2faf8eb515887079d68044ef +Author: Bob +Date: Sat Mar 29 20:16:00 2025 +0300 + + build: добавлен файл проекта + +Коммиты, затрагивающие project.cbp + +платон@WIN-TE35OG7T01L CLANGARM64 ~/Desktop/lab02/alice/project (main) +$ git log -- project.cbp +commit 22b96a493326cbcb2faf8eb515887079d68044ef +Author: Bob +Date: Sat Mar 29 20:16:00 2025 +0300 + + build: добавлен файл проекта + + +Просмотр коммитов + +1) git show HEAD~1 +2) git show main +3) git show 0472419 +платон@WIN-TE35OG7T01L CLANGARM64 ~/Desktop/lab02/alice/project (main) +$ git show HEAD +commit 727003ccbcf1594b14db8f2e68d212c37f65d1d3 (HEAD -> main) +Author: Bob +Date: Sat Mar 29 20:24:30 2025 +0300 + + build: добавлен .gitignore + +diff --git a/.gitignore b/.gitignore +new file mode 100644 +index 0000000..3ff1b43 +--- /dev/null ++++ b/.gitignore +@@ -0,0 +1,3 @@ ++/bin/ ++/obj/ ++*.layout + +Просмотр изменений: + +платон@WIN-TE35OG7T01L CLANGARM64 ~/Desktop/lab02/alice/project (main) +$ git diff +diff --git a/main.cpp b/main.cpp +index 8435233..f372c78 100644 +--- a/main.cpp ++++ b/main.cpp +@@ -8,5 +8,6 @@ int main() + int a, b; + cin >> a >> b; + cout << "A + B = " << a + b << '\n' +- << "A - B = " << a - b << '\n'; # Удаленная строка ++ << "A - B = " << a - b << '\n' # Измененная строка ++ << "A * B = " << a * b << '\n'; # Добавленная строка + } + +2) +платон@WIN-TE35OG7T01L CLANGARM64 ~/Desktop/lab02/alice/project (main) +$ git diff HEAD~3 HEAD~1 +diff --git a/main.cpp b/main.cpp +index b4392ec..8435233 100644 +--- a/main.cpp ++++ b/main.cpp +@@ -4,6 +4,9 @@ using namespace std; + + int main() + { +- cout << "Hello world!" << endl; +- return 0; ++ cout << "Enter A and B: "; ++ int a, b; ++ cin >> a >> b; ++ cout << "A + B = " << a + b << '\n' ++ << "A - B = " << a - b << '\n'; + } + +ОТКАТ ИЗМЕНЕНИЙ + +1)коммит +платон@WIN-TE35OG7T01L CLANGARM64 ~/Desktop/lab02/alice/project (main) +$ git add main.cpp + +платон@WIN-TE35OG7T01L CLANGARM64 ~/Desktop/lab02/alice/project (main) +$ git commit -m "вывод произведения (алиса)" +[main e69bbfc] вывод произведения (алиса) + 1 file changed, 2 insertions(+), 1 deletion(-) + +2)откат изменений +платон@WIN-TE35OG7T01L CLANGARM64 ~/Desktop/lab02/alice/project (main) +$ git reset --hard HEAD~1 +HEAD is now at 727003c build: добавлен .gitignore + +3)добавление комментария +добавил над main комментарий // you may type whatever you want + +платон@WIN-TE35OG7T01L CLANGARM64 ~/Desktop/lab02/alice/project (main) +$ git checkout HEAD -- main.cpp + +проверяю код + +платон@WIN-TE35OG7T01L CLANGARM64 ~/Desktop/lab02/alice/project (main) +$ cat main.cpp +#include + +using namespace std; + +int main() +{ + cout << "Enter A and B: "; + int a, b; + cin >> a >> b; + cout << "A + B = " << a + b << '\n' + << "A - B = " << a - b << '\n'; +} + +ОБМЕН КОДОМ ЧЕРЕЗ УДАЛЕННОЕ ХРАНИЛИЩЕ + +1)зарегался на GIT УИТ +ОТПРАВКА ПРОЕКТА НА СЕРВЕР +1)создал репозитарий cs-lab02 + +!!!поскольку я переделываю лабу и откатывался к коммиту который уже лежит на удаленное хранилище, сначала нужно запушить коммиты алисы: +платон@WIN-TE35OG7T01L CLANGARM64 ~/Desktop/lab02/alice/project (main) +$ git status +On branch main +Your branch is ahead of 'origin/main' by 3 commits. + (use "git push" to publish your local commits) + +платон@WIN-TE35OG7T01L CLANGARM64 ~/Desktop/lab02/alice/project (main) +$ git push origin main +Enumerating objects: 11, done. +Counting objects: 100% (11/11), done. +Delta compression using up to 4 threads +Compressing objects: 100% (8/8), done. +Writing objects: 100% (9/9), 1.41 KiB | 130.00 KiB/s, done. +Total 9 (delta 0), reused 2 (delta 0), pack-reused 0 (from 0) +remote: . Processing 1 references +remote: Processed 1 references in total +To http://uit.mpei.ru/git/MiachinPY/cs-lab02.git + 89f6ee8..727003c main -> main + +еще тут я как то умудрился запушить от имени боба а не Алисы поэтому пришлось делать rebase и менять имя и почту автора + +платон@WIN-TE35OG7T01L CLANGARM64 ~/Desktop/lab02/alice/project (main|REBASE 3/3) +$ git rebase --continue +Successfully rebased and updated refs/heads/main. + +платон@WIN-TE35OG7T01L CLANGARM64 ~/Desktop/lab02/alice/project (main) +$ git push -f origin main +Enumerating objects: 11, done. +Counting objects: 100% (11/11), done. +Delta compression using up to 4 threads +Compressing objects: 100% (8/8), done. +Writing objects: 100% (9/9), 1.47 KiB | 752.00 KiB/s, done. +Total 9 (delta 0), reused 2 (delta 0), pack-reused 0 (from 0) +remote: . Processing 1 references +remote: Processed 1 references in total +To http://uit.mpei.ru/git/MiachinPY/cs-lab02.git + + 727003c...629668c main -> main (forced update) +!!! + +ПОЛУЧЕНИЕ ПРОЕКТА С СЕРВЕРА + +клонирую проект + +платон@WIN-TE35OG7T01L CLANGARM64 ~/Desktop/lab02/bob +$ git clone http://uit.mpei.ru/git/MiachinPY/cs-lab02.git project +Cloning into 'project'... +remote: Enumerating objects: 12, done. +remote: Counting objects: 100% (12/12), done. +remote: Compressing objects: 100% (10/10), done. +remote: Total 12 (delta 0), reused 0 (delta 0), pack-reused 0 +Receiving objects: 100% (12/12), done. + + +перехожу в папку project +платон@WIN-TE35OG7T01L CLANGARM64 ~/Desktop/lab02/bob +$ cd project + +СОВМЕСТНАЯ РАБОТА НАД ПРОЕКТОМ БЕЗ КОНФЛИКТОВ ПРАВОК + +коммит произведения числе от имени боба + +платон@WIN-TE35OG7T01L CLANGARM64 ~/Desktop/lab02/bob/project (main) +$ git add main.cpp + +платон@WIN-TE35OG7T01L CLANGARM64 ~/Desktop/lab02/bob/project (main) +$ git commit -m "code: добавлено произведение (боб)" +[main 74e1269] code: добавлено произведение (боб) + 1 file changed, 2 insertions(+), 1 deletion(-) + +последний коммит + +платон@WIN-TE35OG7T01L CLANGARM64 ~/Desktop/lab02/bob/project (main) +$ git log --oneline +74e1269 (HEAD -> main) code: добавлено произведение (боб) +629668c (origin/main, origin/HEAD) build: добавлен .gitignore +1b276af добавление суммы и разности(алиса) +a5264ef build: добавлен файл проекта +89f6ee8 code: заготовка программы + +платон@WIN-TE35OG7T01L CLANGARM64 ~/Desktop/lab02/bob/project (main) +$ git push +Enumerating objects: 5, done. +Counting objects: 100% (5/5), done. +Delta compression using up to 4 threads +Compressing objects: 100% (3/3), done. +Writing objects: 100% (3/3), 414 bytes | 414.00 KiB/s, done. +Total 3 (delta 1), reused 0 (delta 0), pack-reused 0 (from 0) +remote: . Processing 1 references +remote: Processed 1 references in total +To http://uit.mpei.ru/git/MiachinPY/cs-lab02.git + 629668c..74e1269 main -> main + +в терминале Алисы + +платон@WIN-TE35OG7T01L CLANGARM64 ~/Desktop/lab02/alice/project (main) +$ git fetch +remote: Enumerating objects: 5, done. +remote: Counting objects: 100% (5/5), done. +remote: Compressing objects: 100% (3/3), done. +remote: Total 3 (delta 1), reused 0 (delta 0), pack-reused 0 +Unpacking objects: 100% (3/3), 394 bytes | 49.00 KiB/s, done. +From http://uit.mpei.ru/git/MiachinPY/cs-lab02 + 629668c..74e1269 main -> origin/main + +убеждаюсь что в рабочей копии еще не было изменений + +платон@WIN-TE35OG7T01L CLANGARM64 ~/Desktop/lab02/alice/project (main) +$ git log --oneline --decorate --all --graph +* 74e1269 (origin/main, origin/HEAD) code: добавлено произведение (боб) +* 629668c (HEAD -> main) build: добавлен .gitignore +* 1b276af добавление суммы и разности(алиса) +* a5264ef build: добавлен файл проекта +* 89f6ee8 code: заготовка программы + +платон@WIN-TE35OG7T01L CLANGARM64 ~/Desktop/lab02/alice/project (main) +$ git pull --ff-only +Updating 629668c..74e1269 +Fast-forward + main.cpp | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +убеждаюсь что версии соответствуют + +платон@WIN-TE35OG7T01L CLANGARM64 ~/Desktop/lab02/alice/project (main) +$ git log --oneline +74e1269 (HEAD -> main, origin/main, origin/HEAD) code: добавлено произведение (боб) +629668c build: добавлен .gitignore +1b276af добавление суммы и разности(алиса) +a5264ef build: добавлен файл проекта +89f6ee8 code: заготовка программы + +коммит кода с делением от имени Алисы + +добавляю << "A / B = " << a / b << '\n' + +платон@WIN-TE35OG7T01L CLANGARM64 ~/Desktop/lab02/alice/project (main) +$ git add main.cpp + +платон@WIN-TE35OG7T01L CLANGARM64 ~/Desktop/lab02/alice/project (main) +$ git commit -am "code: добавлено деление (алиса)" +[main 4e26855] code: добавлено деление (алиса) + 1 file changed, 2 insertions(+), 1 deletion(-) + +платон@WIN-TE35OG7T01L CLANGARM64 ~/Desktop/lab02/alice/project (main) +$ git push +Enumerating objects: 5, done. +Counting objects: 100% (5/5), done. +Delta compression using up to 4 threads +Compressing objects: 100% (3/3), done. +Writing objects: 100% (3/3), 417 bytes | 417.00 KiB/s, done. +Total 3 (delta 1), reused 0 (delta 0), pack-reused 0 (from 0) +remote: . Processing 1 references +remote: Processed 1 references in total +To http://uit.mpei.ru/git/MiachinPY/cs-lab02.git + 74e1269..4e26855 main -> main + +синхронизация на машине боба + +платон@WIN-TE35OG7T01L CLANGARM64 ~/Desktop/lab02/bob/project (main) +$ git fetch +remote: Enumerating objects: 5, done. +remote: Counting objects: 100% (5/5), done. +remote: Compressing objects: 100% (3/3), done. +remote: Total 3 (delta 1), reused 0 (delta 0), pack-reused 0 +Unpacking objects: 100% (3/3), 397 bytes | 28.00 KiB/s, done. +From http://uit.mpei.ru/git/MiachinPY/cs-lab02 + 74e1269..4e26855 main -> origin/main + + +платон@WIN-TE35OG7T01L CLANGARM64 ~/Desktop/lab02/bob/project (main) +$ git pull --ff-only +Updating 74e1269..4e26855 +Fast-forward + main.cpp | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +платон@WIN-TE35OG7T01L CLANGARM64 ~/Desktop/lab02/bob/project (main) +$ git log --oneline --decorate --all --graph +* 4e26855 (HEAD -> main, origin/main, origin/HEAD) code: добавлено деление (алиса) +* 74e1269 code: добавлено произведение (боб) +* 629668c build: добавлен .gitignore +* 1b276af добавление суммы и разности(алиса) +* a5264ef build: добавлен файл проекта +* 89f6ee8 code: заготовка программы + +на всякий случай создаю бэкап ветку + +платон@WIN-TE35OG7T01L CLANGARM64 ~/Desktop/lab02/alice/project (main) +$ git checkout -b backup-branch +Switched to a new branch 'backup-branch' + +платон@WIN-TE35OG7T01L CLANGARM64 ~/Desktop/lab02/alice/project (backup-branch) +$ git checkout main +Switched to branch 'main' +Your branch is up to date with 'origin/main'. + +Разрешение конфликтов правок при совместной работе + +~на машине алисы~ + +1) дополнил код << "max(A,B) = " << max(a,b) << '\n' + +платон@WIN-TE35OG7T01L CLANGARM64 ~/Desktop/lab02/alice/project (main) +$ git add main.cpp + +платон@WIN-TE35OG7T01L CLANGARM64 ~/Desktop/lab02/alice/project (main) +$ git commit -m "максимум (алиса)" +[main 51248a8] максимум (алиса) + 1 file changed, 2 insertions(+), 1 deletion(-) + +платон@WIN-TE35OG7T01L CLANGARM64 ~/Desktop/lab02/alice/project (main) +$ git push +Enumerating objects: 5, done. +Counting objects: 100% (5/5), done. +Delta compression using up to 4 threads +Compressing objects: 100% (3/3), done. +Writing objects: 100% (3/3), 406 bytes | 406.00 KiB/s, done. +Total 3 (delta 1), reused 0 (delta 0), pack-reused 0 (from 0) +remote: . Processing 1 references +remote: Processed 1 references in total +To http://uit.mpei.ru/git/MiachinPY/cs-lab02.git + 4e26855..51248a8 main -> main + +~от имени боба~ + +1) дополнил << "min(A,B) = " << min(a,b) << '\n' + +платон@WIN-TE35OG7T01L CLANGARM64 ~/Desktop/lab02/bob/project (main) +$ git add main.cpp + +платон@WIN-TE35OG7T01L CLANGARM64 ~/Desktop/lab02/bob/project (main) +$ git commit -m "максимум (боб)" +[main 236d3a5] максимум (боб) + 1 file changed, 2 insertions(+), 1 deletion(-) + +платон@WIN-TE35OG7T01L CLANGARM64 ~/Desktop/lab02/bob/project (main) +$ git push +To http://uit.mpei.ru/git/MiachinPY/cs-lab02.git + ! [rejected] main -> main (fetch first) +error: failed to push some refs to 'http://uit.mpei.ru/git/MiachinPY/cs-lab02.git' +hint: Updates were rejected because the remote contains work that you do not +hint: have locally. This is usually caused by another repository pushing to +hint: the same ref. If you want to integrate the remote changes, use +hint: 'git pull' before pushing again. +hint: See the 'Note about fast-forwards' in 'git push --help' for details. + +от лица боба загружаю коммиты из удаленного хранилища + +платон@WIN-TE35OG7T01L CLANGARM64 ~/Desktop/lab02/bob/project (main) +$ git fetch +remote: Enumerating objects: 5, done. +remote: Counting objects: 100% (5/5), done. +remote: Compressing objects: 100% (3/3), done. +remote: Total 3 (delta 1), reused 0 (delta 0), pack-reused 0 +Unpacking objects: 100% (3/3), 386 bytes | 25.00 KiB/s, done. +From http://uit.mpei.ru/git/MiachinPY/cs-lab02 + 4e26855..51248a8 main -> origin/main + +платон@WIN-TE35OG7T01L CLANGARM64 ~/Desktop/lab02/bob/project (main) +$ git log --oneline --decorate --all --graph +* 236d3a5 (HEAD -> main) максимум (боб) +| * 51248a8 (origin/main, origin/HEAD) максимум (алиса) +|/ +* 4e26855 code: добавлено деление (алиса) +* 74e1269 code: добавлено произведение (боб) +* 629668c build: добавлен .gitignore +* 1b276af добавление суммы и разности(алиса) +* a5264ef build: добавлен файл проекта +* 89f6ee8 code: заготовка программы + +платон@WIN-TE35OG7T01L CLANGARM64 ~/Desktop/lab02/bob/project (main) +$ git rebase origin/main +Auto-merging main.cpp +CONFLICT (content): Merge conflict in main.cpp +error: could not apply 236d3a5... максимум (боб) +hint: Resolve all conflicts manually, mark them as resolved with +hint: "git add/rm ", then run "git rebase --continue". +hint: You can instead skip this commit: run "git rebase --skip". +hint: To abort and get back to the state before "git rebase", run "git rebase --abort". +hint: Disable this message with "git config set advice.mergeConflict false" +Could not apply 236d3a5... максимум (боб) + +просмотр состояния хранилища + +платон@WIN-TE35OG7T01L CLANGARM64 ~/Desktop/lab02/bob/project (main|REBASE 1/1) +$ git status +interactive rebase in progress; onto 2676e8e +Last command done (1 command done): + pick a8ac6ae Добавлен вывод минимума (Боб) +No commands remaining. +You are currently rebasing branch 'main' on '2676e8e'. + (fix conflicts and then run "git rebase --continue") + (use "git rebase --skip" to skip this patch) + (use "git rebase --abort" to check out the original branch) + +Unmerged paths: + (use "git restore --staged ..." to unstage) + (use "git add ..." to mark resolution) + both modified: main.cpp -- main.cpp изменен и в коммите алисы (2676e8e), и в коммите боба (a8ac6ae) + +Untracked files: + (use "git add ..." to include in what will be committed) + bin/ + obj/ + +no changes added to commit (use "git add" and/or "git commit -a") + +код в codeblocks у боба: + +#include + +using namespace std; + +int main() +{ + cout << "Enter A and B: "; + int a, b; + cin >> a >> b; + cout << "A + B = " << a + b << '\n' + << "A - B = " << a - b << '\n' + << "A * B = " << a * b << '\n' + << "A / B = " << a / b << '\n' +<<<<<<< HEAD + << "max(A,B) = " << max(a,b) << '\n'; +======= + << "min(A,B) = " << min(a,b) << '\n'; +>>>>>>> 236d3a5 (максимум (боб)) +} + +редактирую код + +#include + +using namespace std; + +int main() +{ + cout << "Enter A and B: "; + int a, b; + cin >> a >> b; + cout << "A + B = " << a + b << '\n' + << "A - B = " << a - b << '\n' + << "A * B = " << a * b << '\n' + << "A / B = " << a / b << '\n' + << "min(A,B) = " << min(a,b) << '\n'; + << "max(A,B) = " << max(a,b) << '\n'; +} + +компилирую, конфликт разрешен + +платон@WIN-TE35OG7T01L CLANGARM64 ~/Desktop/lab02/bob/project (main|MERGING) +$ git add main.cpp +$ git rebase --continue + +interactive rebase in progress; onto 2676e8e +Last command done (1 command done): + pick a8ac6ae Добавлен вывод минимума (Боб) +Добавлен вывод минимума (Боб) + +[detached HEAD 27cd247] максимум (боб) + 1 file changed, 2 insertions(+), 1 deletion(-) +Successfully rebased and updated refs/heads/main. + +просмотр истории + +платон@WIN-TE35OG7T01L CLANGARM64 ~/Desktop/lab02/bob/project (main) +$ git log --oneline --decorate --all --graph +* 27cd247 (HEAD -> main) максимум (боб) +* 51248a8 (origin/main, origin/HEAD) максимум (алиса) +* 4e26855 code: добавлено деление (алиса) +* 74e1269 code: добавлено произведение (боб) +* 629668c build: добавлен .gitignore +* 1b276af добавление суммы и разности(алиса) +* a5264ef build: добавлен файл проекта +* 89f6ee8 code: заготовка программы + +пуш на сервер + +платон@WIN-TE35OG7T01L CLANGARM64 ~/Desktop/lab02/bob/project (main) +$ git push -f origin main +Enumerating objects: 5, done. +Counting objects: 100% (5/5), done. +Delta compression using up to 4 threads +Compressing objects: 100% (3/3), done. +Writing objects: 100% (3/3), 403 bytes | 403.00 KiB/s, done. +Total 3 (delta 1), reused 0 (delta 0), pack-reused 0 (from 0) +remote: . Processing 1 references +remote: Processed 1 references in total +To http://uit.mpei.ru/git/MiachinPY/cs-lab02.git + 51248a8..27cd247 main -> main + +Использование веток + +платон@WIN-TE35OG7T01L CLANGARM64 ~/Desktop/lab02/alice/project (main) +$ git branch double + +платон@WIN-TE35OG7T01L CLANGARM64 ~/Desktop/lab02/alice/project (main) +$ git checkout double +Switched to branch 'double' + +меняю тип данных на double + +платон@WIN-TE35OG7T01L CLANGARM64 ~/Desktop/lab02/alice/project (double) +$ git add main.cpp + +платон@WIN-TE35OG7T01L CLANGARM64 ~/Desktop/lab02/alice/project (double) +$ git commit -am "code: вещественный тип данных (алиса)" +[double ddf1e73] code: вещественный тип данных (алиса) + 1 file changed, 1 insertion(+), 1 deletion(-) + +платон@WIN-TE35OG7T01L CLANGARM64 ~/Desktop/lab02/alice/project (double) +$ git checkout main +M main.cpp +Switched to branch 'main' +Your branch is up to date with 'origin/main'. + +синхронизация ветки на машине Алисы + +платон@WIN-TE35OG7T01L CLANGARM64 ~/Desktop/lab02/alice/project (main) +$ git fetch origin +remote: Enumerating objects: 5, done. +remote: Counting objects: 100% (5/5), done. +remote: Compressing objects: 100% (3/3), done. +remote: Total 3 (delta 1), reused 0 (delta 0), pack-reused 0 +Unpacking objects: 100% (3/3), 383 bytes | 22.00 KiB/s, done. +From http://uit.mpei.ru/git/MiachinPY/cs-lab02 + 51248a8..27cd247 main -> origin/main + +платон@WIN-TE35OG7T01L CLANGARM64 ~/Desktop/lab02/alice/project (main) +$ git pull --ff-only origin main +From http://uit.mpei.ru/git/MiachinPY/cs-lab02 + * branch main -> FETCH_HEAD +Updating 51248a8..27cd247 +Fast-forward + main.cpp | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +платон@WIN-TE35OG7T01L CLANGARM64 ~/Desktop/lab02/alice/project (main) +$ git log --all --graph --oneline --decorate +* f73e3c4 (double) Изменение типа переменных на double (Алиса) +* 25f947f (HEAD -> main, origin/main, origin/HEAD) Добавлен вывод минимума (Боб) +* 2676e8e код с выводом максимума от алисы +* 4137942 финальный код от алисы +* 1cab061 коммит боба +* cec8e0a build: добавление файлов +* 0472419 build: добавлен файл проекта +* 89f6ee8 code: заготовка программы + +Auto-merging main.cpp +Merge made by the 'ort' strategy. + main.cpp | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +платон@WIN-TE35OG7T01L CLANGARM64 ~/Desktop/lab02/alice/project (main) +$ git push origin main +Enumerating objects: 10, done. +Counting objects: 100% (10/10), done. +Delta compression using up to 4 threads +Compressing objects: 100% (6/6), done. +Writing objects: 100% (6/6), 806 bytes | 403.00 KiB/s, done. +Total 6 (delta 2), reused 0 (delta 0), pack-reused 0 (from 0) +remote: . Processing 1 references +remote: Processed 1 references in total +To http://uit.mpei.ru/git/MiachinPY/cs-lab02.git + 27cd247..1752ffb main -> main