34 KiB
Отчет по лабораторной работе № 2 «Система контроля версий Git»
Выполнил: Иванов Д. А.
Группа: А-01-23
Проверил: Козлюк Д. А.
-
Создал в именной папке каталог 2lab
-
Создал каталоги
Alice
,Bob
, внутри каталогаAlice
создал каталогproject
:
justygrass@DESKTOP-GQCR3HF MINGW64 ~/Desktop/2lab
$ mkdir Alice
justygrass@DESKTOP-GQCR3HF MINGW64 ~/Desktop/2lab
$ mkdir Bob
justygrass@DESKTOP-GQCR3HF MINGW64 ~/Desktop/2lab
$ cd Alice
justygrass@DESKTOP-GQCR3HF MINGW64 ~/Desktop/2lab/Alice
$ mkdir project
justygrass@DESKTOP-GQCR3HF MINGW64 ~/Desktop/2lab/Alice
$ cd project
justygrass@DESKTOP-GQCR3HF MINGW64 ~/Desktop/2lab/Alice/project
$ cd ..
justygrass@DESKTOP-GQCR3HF MINGW64 ~/Desktop/2lab/Alice
$ cd project
- Инициализировал репозитарий
justygrass@DESKTOP-GQCR3HF MINGW64 ~/Desktop/2lab/Alice/project
$ git init
Initialized empty Git repository in C:/Users/justygrass/Desktop/2lab/Alice/project/.git/
- Добавил данные email и инициалы для
Alice
justygrass@DESKTOP-GQCR3HF MINGW64 ~/Desktop/2lab/Alice/project
$ git config user.name 'Alice (IvanovDA)'
justygrass@DESKTOP-GQCR3HF MINGW64 ~/Desktop/2lab/Alice/project
$ git config user.email 'IvanovDanAn@mpei.ru'
- Просмотр статуса репозитария
justygrass@DESKTOP-GQCR3HF MINGW64 ~/Desktop/2lab/Alice/project (master)
$ git status
On branch master
No commits yet
Untracked files:
(use "git add <file>..." to include in what will be committed)
.vs/
project.sln
project.vcxproj
project.vcxproj.filters
project.vcxproj.user
project/
main.cpp
nothing added to commit but untracked files present (use "git add" to track)
Можно увидеть то, на какой ветке мы находимся, и перечень файлов, которые ещё не были занесены в git и отсутствие коммитов
- Добавим в git файл
main.cpp
и сразу же проверим статус
justygrass@DESKTOP-GQCR3HF MINGW64 ~/Desktop/2lab/Alice/project (master)
$ git add main.cpp
justygrass@DESKTOP-GQCR3HF MINGW64 ~/Desktop/2lab/Alice/project (master)
$ git status
On branch master
No commits yet
Changes to be committed:
(use "git rm --cached <file>..." to unstage)
new file: main.cpp
Untracked files:
(use "git add <file>..." to include in what will be committed)
.vs/
project.sln
project.vcxproj
project.vcxproj.filters
project.vcxproj.user
project/
justygrass@DESKTOP-GQCR3HF MINGW64 ~/Desktop/2lab/Alice/project (master)
$ git commit -m 'code: заготовка программы'
[master (root-commit) fcbb7f4] code: заготовка программы
1 file changed, 7 insertions(+)
create mode 100644 main.cpp
git status
показывает, что в следующий коммит войдет main.cpp
- Закоммитим данное добавление
justygrass@DESKTOP-GQCR3HF MINGW64 ~/Desktop/2lab/Alice/project (master)
$ git commit -m 'code: заготовка программы'
[master (root-commit) fcbb7f4] code: заготовка программы
1 file changed, 7 insertions(+)
create mode 100644 main.cpp
- Добавим файл проекта в
git
и сразу же добавим коммит
justygrass@DESKTOP-GQCR3HF MINGW64 ~/Desktop/2lab/Alice/project (master)
$ git add project.sln
justygrass@DESKTOP-GQCR3HF MINGW64 ~/Desktop/2lab/Alice/project (master)
$ git commit -m 'build: добавление файла проекта'
[master 7c497ed] build: добавление файла проекта
1 file changed, 31 insertions(+)
create mode 100644 project.sln
- Изменим
main.cpp
, но не добавим его вgit
, проверим статус репозитария
justygrass@DESKTOP-GQCR3HF MINGW64 ~/Desktop/2lab/Alice/project (master)
$ git status
On branch master
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
modified: main.cpp
Untracked files:
(use "git add <file>..." to include in what will be committed)
.vs/
project.vcxproj
project.vcxproj.filters
project.vcxproj.user
project/
no changes added to commit (use "git add" and/or "git commit -a")
Мы также остались на ветке master
, и также показываются файлы, созданные Visual Studio, которые ещё не были занесены в git
. Также можно заметить, что main.cpp
был modified
и должен быть добавлен заново.
- Добавим
main.cpp
снова и коммит, сообщающий о добавление тела функции
ustygrass@DESKTOP-GQCR3HF MINGW64 ~/Desktop/2lab/Alice/project (master)
$ git add main.cpp
justygrass@DESKTOP-GQCR3HF MINGW64 ~/Desktop/2lab/Alice/project (master)
$ git commit -m "code: добавления тела функции"
[master f9a4e3d] code: добавления тела функции
1 file changed, 3 insertions(+), 1 deletion(-)
- Добавим ещё дополнительные изменения в функцию и попробуем разные способы добавления коммитов
justygrass@DESKTOP-GQCR3HF MINGW64 ~/Desktop/2lab/Alice/project (master)
$ git add -u
justygrass@DESKTOP-GQCR3HF MINGW64 ~/Desktop/2lab/Alice/project (master)
$ git commit -m "code: добавление вывода суммы A и B"
[master 40c11d1] code: добавление вывода суммы A и B
1 file changed, 1 insertion(+)
justygrass@DESKTOP-GQCR3HF MINGW64 ~/Desktop/2lab/Alice/project (master)
$ git commit -a -m "code: добавление вывода разности A и B"
[master 822e111] code: добавление вывода разности A и B
1 file changed, 2 insertions(+), 1 deletion(-)
- Добавим файл
.gitignore
для того, чтобы не вылезали сообщения о файлах при командеgit status
justygrass@DESKTOP-GQCR3HF MINGW64 ~/Desktop/2lab/Alice/project (master)
$ git add .gitignore
justygrass@DESKTOP-GQCR3HF MINGW64 ~/Desktop/2lab/Alice/project (master)
$ git commit -m "git: добавление игнорирование файлов"
[master ead7cbd] git: добавление игнорирование файлов
1 file changed, 5 insertions(+)
create mode 100644 .gitignore
- Просмотр коммитов 3 разными способами, указзанными в руководстве
justygrass@DESKTOP-GQCR3HF MINGW64 ~/Desktop/2lab/Alice/project (master)
$ git log
commit ead7cbd6046048e7caeadb610eb13e6d9d83b2db (HEAD -> master)
Author: Alice(IvanovDA) <IvanovDanAn@mpei.ru>
Date: Sun Mar 31 20:49:20 2024 +0300
git: добавление игнорирование файлов
commit 822e1116aeac88d14a6e7f366ce94f69e85021fe
Author: Alice(IvanovDA) <IvanovDanAn@mpei.ru>
Date: Sun Mar 31 20:41:45 2024 +0300
code: добавление вывода разности A и B
commit 40c11d18429373631314da1617a6cfbf6baa289f
Author: Alice(IvanovDA) <IvanovDanAn@mpei.ru>
Date: Sun Mar 31 20:40:33 2024 +0300
code: добавление вывода суммы A и B
commit f9a4e3dac2e1b1a093ccb20f6611dbc2643b8aa8
Author: Alice(IvanovDA) <IvanovDanAn@mpei.ru>
Date: Sun Mar 31 20:39:06 2024 +0300
code: добавления тела функции
commit 7c497ed7031a3d915d7d1b86909c3437af25ede7
Author: Alice(IvanovDA) <IvanovDanAn@mpei.ru>
Date: Sun Mar 31 20:34:05 2024 +0300
build: добавление файла проекта
commit fcbb7f47c62ef3082b670a031d6938ff92757230
Author: Alice(IvanovDA) <IvanovDanAn@mpei.ru>
Date: Sun Mar 31 20:25:37 2024 +0300
code: заготовка программы
justygrass@DESKTOP-GQCR3HF MINGW64 ~/Desktop/2lab/Alice/project (master)
$ git log --stat
commit ead7cbd6046048e7caeadb610eb13e6d9d83b2db (HEAD -> master)
Author: Alice(IvanovDA) <IvanovDanAn@mpei.ru>
Date: Sun Mar 31 20:49:20 2024 +0300
git: добавление игнорирование файлов
.gitignore | 5 +++++
1 file changed, 5 insertions(+)
commit 822e1116aeac88d14a6e7f366ce94f69e85021fe
Author: Alice(IvanovDA) <IvanovDanAn@mpei.ru>
Date: Sun Mar 31 20:41:45 2024 +0300
code: добавление вывода разности A и B
main.cpp | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
commit 40c11d18429373631314da1617a6cfbf6baa289f
Author: Alice(IvanovDA) <IvanovDanAn@mpei.ru>
Date: Sun Mar 31 20:40:33 2024 +0300
code: добавление вывода суммы A и B
main.cpp | 1 +
1 file changed, 1 insertion(+)
commit f9a4e3dac2e1b1a093ccb20f6611dbc2643b8aa8
Author: Alice(IvanovDA) <IvanovDanAn@mpei.ru>
Date: Sun Mar 31 20:39:06 2024 +0300
code: добавления тела функции
main.cpp | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
justygrass@DESKTOP-GQCR3HF MINGW64 ~/Desktop/2lab/Alice/project (master)
$ git log --oneline --decorate
ead7cbd (HEAD -> master) git: добавление игнорирование файлов
822e111 code: добавление вывода разности A и B
40c11d1 code: добавление вывода суммы A и B
f9a4e3d code: добавления тела функции
7c497ed build: добавление файла проекта
fcbb7f4 code: заготовка программы
justygrass@DESKTOP-GQCR3HF MINGW64 ~/Desktop/2lab/Alice/project (master)
$ git log --oneline --decorate --all --graph
* ead7cbd (HEAD -> master) git: добавление игнорирование файлов
* 822e111 code: добавление вывода разности A и B
* 40c11d1 code: добавление вывода суммы A и B
* f9a4e3d code: добавления тела функции
* 7c497ed build: добавление файла проекта
* fcbb7f4 code: заготовка программы
- Просмотрим коммиты, в которых встречалось
build:
justygrass@DESKTOP-GQCR3HF MINGW64 ~/Desktop/2lab/Alice/project (master)
$ git log --grep "build:"
commit 7c497ed7031a3d915d7d1b86909c3437af25ede7
Author: Alice(IvanovDA) <IvanovDanAn@mpei.ru>
Date: Sun Mar 31 20:34:05 2024 +0300
build: добавление файла проекта
А также просмотрим коммиты, связанные с файлом проекта
justygrass@DESKTOP-GQCR3HF MINGW64 ~/Desktop/2lab/Alice/project (master)
$ git log -- project.sln
commit 7c497ed7031a3d915d7d1b86909c3437af25ede7
Author: Alice(IvanovDA) <IvanovDanAn@mpei.ru>
Date: Sun Mar 31 20:34:05 2024 +0300
build: добавление файла проекта
- Заметил, что ветка все ещё называется
master
, переименую ветку
justygrass@DESKTOP-GQCR3HF MINGW64 ~/Desktop/2lab/Alice/project (master)
$ git branch -m main
- Просмотрим предпоследний коммит, для этого подойдут 3 команды, но вывод будет указан единожды
justygrass@DESKTOP-GQCR3HF MINGW64 ~/Desktop/2lab/Alice/project (main)
$ git show HEAD~1
justygrass@DESKTOP-GQCR3HF MINGW64 ~/Desktop/2lab/Alice/project (main)
$ git show main~1
justygrass@DESKTOP-GQCR3HF MINGW64 ~/Desktop/2lab/Alice/project (main)
$ git show 822e111
commit 822e1116aeac88d14a6e7f366ce94f69e85021fe
Author: Alice(IvanovDA) <IvanovDanAn@mpei.ru>
Date: Sun Mar 31 20:41:45 2024 +0300
code: добавление вывода разности A и B
diff --git a/main.cpp b/main.cpp
index 55182f2..a1f2e7d 100644
--- a/main.cpp
+++ b/main.cpp
@@ -5,6 +5,7 @@ int main(){
cout << "Enter A and B: ";
int a, b;
cin >> a >> b;
- cout << "A + B = " << a + b << '\n';
+ cout << "A + B = " << a + b << '\n'
+ << "A - B = " << a - b << '\n';
return 0;
}
\ No newline at end of file
- Добавим в функцию вывод произведения, но пока что не будем коммитить, просмотрим изменения
justygrass@DESKTOP-GQCR3HF MINGW64 ~/Desktop/2lab/Alice/project (main)
$ git diff
diff --git a/main.cpp b/main.cpp
index a1f2e7d..fe5b162 100644
--- a/main.cpp
+++ b/main.cpp
@@ -6,6 +6,7 @@ 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';
return 0;
}
\ No newline at end of file
Можно заметить, что у новых и старых строчек появились символы -
и +
, что показывают что строчка исчезла и добавилась соответственно
- Просмотрим разницу между самым первым коммитов и тем, что добавлял вывод разницы чисел
justygrass@DESKTOP-GQCR3HF MINGW64 ~/Desktop/2lab/Alice/project (main)
$ git diff fcbb7f4 822e111
diff --git a/main.cpp b/main.cpp
index 86a6d86..a1f2e7d 100644
--- a/main.cpp
+++ b/main.cpp
@@ -2,6 +2,10 @@
using namespace std:
int main(){
- cout << 'I love Paris';
+ cout << "Enter A and B: ";
+ int a, b;
+ cin >> a >> b;
+ cout << "A + B = " << a + b << '\n'
+ << "A - B = " << a - b << '\n';
return 0;
}
\ No newline at end of file
diff --git a/project.sln b/project.sln
new file mode 100644
index 0000000..9304397
--- /dev/null
+++ b/project.sln
@@ -0,0 +1,31 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio Version 17
+VisualStudioVersion = 17.9.34701.34
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "project", "project.vcxproj", "{77C4033C-66D6-4F32-8063-AF97F34F2C9F}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|x64 = Debug|x64
+ Debug|x86 = Debug|x86
Можно заметить, что за все время убралась строчка с выводом сообщения I love Paris
, которая находилась изначально в файле, и добавились все оставшиеся строчки, принадлежащие текущему телу функции
- Закоммитим добавление вывода произведения
justygrass@DESKTOP-GQCR3HF MINGW64 ~/Desktop/2lab/Alice/project (main)
$ git commit -a -m "code: добавление вывода произведения A и В"
[main e56c823] code: добавление вывода произведения A и В
1 file changed, 2 insertions(+), 1 deletion(-)
- Сделаем откат к предыдущему коммиту
justygrass@DESKTOP-GQCR3HF MINGW64 ~/Desktop/2lab/Alice/project (main)
$ git reset --hard HEAD~1
HEAD is now at ead7cbd git: добавление игнорирование файлов
- Добавим над функцией
main()
любой комментарий, после чего сразу же совершим откат к состоянию последнего коммита
justygrass@DESKTOP-GQCR3HF MINGW64 ~/Desktop/2lab/Alice/project (main)
$ git checkout HEAD -- main.cpp
- В виду того, что я проживаю в общежитии и у меня были проблемы с подключением в сервису VPN МЭИ, пришлось работать с HTTTP вместо SSH
justygrass@DESKTOP-GQCR3HF MINGW64 ~/Desktop/2lab/Alice/project (main)
$ git remote add origin http://uit.mpei.ru/git/IvanovDanAn/cs-lab02.git
justygrass@DESKTOP-GQCR3HF MINGW64 ~/Desktop/2lab/Alice/project (main)
$ git push -u origin main
warning: auto-detection of host provider took too long (>2000ms)
warning: see https://aka.ms/gcm/autodetect for more information.
warning: auto-detection of host provider took too long (>2000ms)
warning: see https://aka.ms/gcm/autodetect for more information.
Enumerating objects: 18, done.
Counting objects: 100% (18/18), done.
Delta compression using up to 16 threads
Compressing objects: 100% (17/17), done.
Writing objects: 100% (18/18), 2.50 KiB | 2.50 MiB/s, done.
Total 18 (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/IvanovDanAn/cs-lab02.git
* [new branch] main -> main
branch 'main' set up to track 'origin/main'.
- Окроем GIT на машине Боба. Клонируем репозитарий с облака в папку Боба строителя, после чего перейдем в папку проекта. Случайно упустил момент именования папки проекта, поэтому вместо
project
далее будет указан каталогcs-lab02
justygrass@DESKTOP-GQCR3HF MINGW64 ~/Desktop/2lab/Bob
$ git clone http://uit.mpei.ru/git/IvanovDanAn/cs-lab02.git
Cloning into 'cs-lab02'...
remote: Enumerating objects: 18, done.
remote: Counting objects: 100% (18/18), done.
remote: Compressing objects: 100% (17/17), done.
remote: Total 18 (delta 2), reused 0 (delta 0), pack-reused 0
Receiving objects: 100% (18/18), done.
Resolving deltas: 100% (2/2), done.
justygrass@DESKTOP-GQCR3HF MINGW64 ~/Desktop/2lab/Bob
$ cd cs-lab02/
- Повторим те же действия с добавлением почты и имени Бобу
justygrass@DESKTOP-GQCR3HF MINGW64 ~/Desktop/2lab/Bob/cs-lab02 (main)
$ git config user.name 'Bob (IvanovDA)'
justygrass@DESKTOP-GQCR3HF MINGW64 ~/Desktop/2lab/Bob/cs-lab02 (main)
$ git config user.email 'IvanovDanAn@mpei.ru'
- Добавим вывод частного от лица боба и закоммитим вывод произведения, после чего сразу отправим изменения
justygrass@DESKTOP-GQCR3HF MINGW64 ~/Desktop/2lab/Bob/cs-lab02 (main)
$ git commit -a -m "code: добавление вывода произведения A и В"
[main cbc1285] code: добавление вывода произведения A и В
1 file changed, 2 insertions(+), 1 deletion(-)
justygrass@DESKTOP-GQCR3HF MINGW64 ~/Desktop/2lab/Bob/cs-lab02 (main)
$ git push
warning: auto-detection of host provider took too long (>2000ms)
warning: see https://aka.ms/gcm/autodetect for more information.
warning: auto-detection of host provider took too long (>2000ms)
warning: see https://aka.ms/gcm/autodetect for more information.
Enumerating objects: 5, done.
Counting objects: 100% (5/5), done.
Delta compression using up to 16 threads
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 446 bytes | 446.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/IvanovDanAn/cs-lab02.git
ead7cbd..cbc1285 main -> main
- Обновим проект на машине Алисы
justygrass@DESKTOP-GQCR3HF MINGW64 ~/Desktop/2lab/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), 426 bytes | 142.00 KiB/s, done.
From http://uit.mpei.ru/git/IvanovDanAn/cs-lab02
ead7cbd..cbc1285 main -> origin/main
justygrass@DESKTOP-GQCR3HF MINGW64 ~/Desktop/2lab/Alice/project (main)
$ git log --oneline --decorate --all --graph
* cbc1285 (origin/main) code: добавление вывода произведения A и В
* ead7cbd (HEAD -> main) git: добавление игнорирование файлов
* 822e111 code: добавление вывода разности A и B
* 40c11d1 code: добавление вывода суммы A и B
* f9a4e3d code: добавления тела функции
* 7c497ed build: добавление файла проекта
* fcbb7f4 code: заготовка программы
justygrass@DESKTOP-GQCR3HF MINGW64 ~/Desktop/2lab/Alice/project (main)
$ git pull --ff-only
Updating ead7cbd..cbc1285
Fast-forward
main.cpp | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
После первой команды можно увидеть, что состояние проекта отстает на один коммит, поэтому сразу же пододвинем ветку Алисы к текущей
- С машины Алисы сделаем вывод частного чисел, закоммитим и отправим измененные данные на сервер
justygrass@DESKTOP-GQCR3HF MINGW64 ~/Desktop/2lab/Alice/project (main)
$ git commit -a -m "code: добавление вывода частного А и В"
[main 57ab0f9] code: добавление вывода частного А и В
1 file changed, 2 insertions(+), 1 deletion(-)
justygrass@DESKTOP-GQCR3HF MINGW64 ~/Desktop/2lab/Alice/project (main)
$ git push
warning: auto-detection of host provider took too long (>2000ms)
warning: see https://aka.ms/gcm/autodetect for more information.
warning: auto-detection of host provider took too long (>2000ms)
warning: see https://aka.ms/gcm/autodetect for more information.
Enumerating objects: 5, done.
Counting objects: 100% (5/5), done.
Delta compression using up to 16 threads
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 445 bytes | 445.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/IvanovDanAn/cs-lab02.git
cbc1285..57ab0f9 main -> main
- На машину Боба загрузим изменения Алисы
justygrass@DESKTOP-GQCR3HF MINGW64 ~/Desktop/2lab/Bob/cs-lab02 (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), 425 bytes | 32.00 KiB/s, done.
From http://uit.mpei.ru/git/IvanovDanAn/cs-lab02
cbc1285..57ab0f9 main -> origin/main
justygrass@DESKTOP-GQCR3HF MINGW64 ~/Desktop/2lab/Bob/cs-lab02 (main)
$ git pull --ff-only
Updating cbc1285..57ab0f9
Fast-forward
main.cpp | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
- На машине Алисы добавим в программу вывод максимума, после чего закоммитим и отправим на сервер, затем сделаем на машине Боба вывод минимума и тоже закоммитим, после чего попытаемся загрузить изменения на сервер
justygrass@DESKTOP-GQCR3HF MINGW64 ~/Desktop/2lab/Alice/project (main)
$ git commit -a -m "code: добавление вывода максимума"
[main 749a41e] code: добавление вывода максимума
1 file changed, 2 insertions(+), 1 deletion(-)
justygrass@DESKTOP-GQCR3HF MINGW64 ~/Desktop/2lab/Alice/project (main)
$ git push
warning: auto-detection of host provider took too long (>2000ms)
warning: see https://aka.ms/gcm/autodetect for more information.
warning: auto-detection of host provider took too long (>2000ms)
warning: see https://aka.ms/gcm/autodetect for more information.
Enumerating objects: 5, done.
Counting objects: 100% (5/5), done.
Delta compression using up to 16 threads
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 452 bytes | 452.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/IvanovDanAn/cs-lab02.git
57ab0f9..749a41e main -> main
justygrass@DESKTOP-GQCR3HF MINGW64 ~/Desktop/2lab/Bob/cs-lab02 (main)
$ git commit -a -m "code: добавление вывода минимального значения"
[main e312366] code: добавление вывода минимального значения
1 file changed, 2 insertions(+), 1 deletion(-)
justygrass@DESKTOP-GQCR3HF MINGW64 ~/Desktop/2lab/Bob/cs-lab02 (main)
$ git push
warning: auto-detection of host provider took too long (>2000ms)
warning: see https://aka.ms/gcm/autodetect for more information.
warning: auto-detection of host provider took too long (>2000ms)
warning: see https://aka.ms/gcm/autodetect for more information.
To http://uit.mpei.ru/git/IvanovDanAn/cs-lab02.git
! [rejected] main -> main (fetch first)
error: failed to push some refs to 'http://uit.mpei.ru/git/IvanovDanAn/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.
Как было сказано до этого, я проживаю в общежитии, поэтому соединение оставляет желать лучшего, из-за чего появляется сообщение о слишком долгом ответе >2000ms
Выдвинуть изменения Боба не получилось, вышла ошибка, в виду того, что программа Боба не соответствовала той, что присутствовала на сервере
- Просмотрим историю коммитов, но перед этим загрузим их
justygrass@DESKTOP-GQCR3HF MINGW64 ~/Desktop/2lab/Bob/cs-lab02 (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), 432 bytes | 54.00 KiB/s, done.
From http://uit.mpei.ru/git/IvanovDanAn/cs-lab02
57ab0f9..749a41e main -> origin/main
justygrass@DESKTOP-GQCR3HF MINGW64 ~/Desktop/2lab/Bob/cs-lab02 (main)
$ git log --oneline --decorate
e312366 (HEAD -> main) code: добавление вывода минимального значения
57ab0f9 code: добавление вывода частного А и В
cbc1285 code: добавление вывода произведения A и В
ead7cbd git: добавление игнорирование файлов
822e111 code: добавление вывода разности A и B
40c11d1 code: добавление вывода суммы A и B
f9a4e3d code: добавления тела функции
7c497ed build: добавление файла проекта
fcbb7f4 code: заготовка программы
Нетрудно заметить, что появилось две ветки main
- Попытаемся переместить коммит Боба поверх коммита Алисы
justygrass@DESKTOP-GQCR3HF MINGW64 ~/Desktop/2lab/Bob/cs-lab02 (main)
$ git rebase origin/main
Auto-merging main.cpp
CONFLICT (content): Merge conflict in main.cpp
error: could not apply e312366... code: добавление вывода минимального значения
hint: Resolve all conflicts manually, mark them as resolved with
hint: "git add/rm <conflicted_files>", 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".
Could not apply e312366... code: добавление вывода минимального значения
К сожалению нам не дают этого сделать, поэтому придется вручную привести код Боба к тому, чтобы он совпадал с кодом Алисы
- Нужно продолжить оборванную команду
rebase
, но прежде добавить измененный Бобом файл
justygrass@DESKTOP-GQCR3HF MINGW64 ~/Desktop/2lab/Bob/cs-lab02 (main|REBASE 1/1)
$ git add main.cpp
justygrass@DESKTOP-GQCR3HF MINGW64 ~/Desktop/2lab/Bob/cs-lab02 (main|REBASE 1/1)
$ git rebase --continue
Successfully rebased and updated refs/heads/main.
justygrass@DESKTOP-GQCR3HF MINGW64 ~/Desktop/2lab/Bob/cs-lab02 (main)
$ git push
warning: auto-detection of host provider took too long (>2000ms)
warning: see https://aka.ms/gcm/autodetect for more information.
warning: auto-detection of host provider took too long (>2000ms)
warning: see https://aka.ms/gcm/autodetect for more information.
Enumerating objects: 5, done.
Counting objects: 100% (5/5), done.
Delta compression using up to 16 threads
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 468 bytes | 468.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/IvanovDanAn/cs-lab02.git
749a41e..b17facd main -> main
- Перейдем на ветку Алисы и создадим новую ветку для изменения типа переменных - ветку
double
justygrass@DESKTOP-GQCR3HF MINGW64 ~/Desktop/2lab/Alice/project (main)
$ git branch double
justygrass@DESKTOP-GQCR3HF MINGW64 ~/Desktop/2lab/Alice/project (main)
$ git checkout double
Switched to branch 'double'
Сразу же перейдем на новую ветку
- Поменяем код с изменением типа данных, добавим файл и закоммитим изменения
justygrass@DESKTOP-GQCR3HF MINGW64 ~/Desktop/2lab/Alice/project (double)
$ git commit -a -m "code: изменение типа данных на double"
[double c27acd9] code: изменение типа данных на double
1 file changed, 1 insertion(+), 1 deletion(-)
- Перейдем на ветку
main
, синхронизируем репозитарий и просмотрим историю
justygrass@DESKTOP-GQCR3HF MINGW64 ~/Desktop/2lab/Alice/project (double)
$ git checkout main
Switched to branch 'main'
Your branch is up to date with 'origin/main'.
justygrass@DESKTOP-GQCR3HF MINGW64 ~/Desktop/2lab/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), 448 bytes | 49.00 KiB/s, done.
From http://uit.mpei.ru/git/IvanovDanAn/cs-lab02
749a41e..b17facd main -> origin/main
justygrass@DESKTOP-GQCR3HF MINGW64 ~/Desktop/2lab/Alice/project (main)
$ git pull --ff-only
Updating 749a41e..b17facd
Fast-forward
main.cpp | 1 +
1 file changed, 1 insertion(+)
justygrass@DESKTOP-GQCR3HF MINGW64 ~/Desktop/2lab/Alice/project (main)
$ git log --oneline --decorate --all --graph
* c27acd9 (double) code: изменение типа данных на double
| * b17facd (HEAD -> main, origin/main) code: добавление вывода минимального значения
|/
* 749a41e code: добавление вывода максимума
* 57ab0f9 code: добавление вывода частного А и В
* cbc1285 code: добавление вывода произведения A и В
* ead7cbd git: добавление игнорирование файлов
* 822e111 code: добавление вывода разности A и B
* 40c11d1 code: добавление вывода суммы A и B
* f9a4e3d code: добавления тела функции
* 7c497ed build: добавление файла проекта
* fcbb7f4 code: заготовка программы
Можно заметить, что ветки Алисы и Боба совпадают, но хэш c27acd9
последнего коммита принадлежит ветке double
- Сольем две ветки:
main
иdouble
justygrass@DESKTOP-GQCR3HF MINGW64 ~/Desktop/2lab/Alice/project (main)
$ git merge double
Auto-merging main.cpp
Merge made by the 'ort' strategy.
main.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
- Отправим измения ветки на сервер
justygrass@DESKTOP-GQCR3HF MINGW64 ~/Desktop/2lab/Alice/project (main)
$ git push
Enumerating objects: 10, done.
Counting objects: 100% (10/10), done.
Delta compression using up to 16 threads
Compressing objects: 100% (6/6), done.
Writing objects: 100% (6/6), 773 bytes | 773.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/IvanovDanAn/cs-lab02.git
b17facd..b63c04f main -> main
- Просмотрим историю всех веток репозитария
justygrass@DESKTOP-GQCR3HF MINGW64 ~/Desktop/2lab/Alice/project (main)
$ git log --oneline --decorate --all --graph
* b63c04f (HEAD -> main, origin/main) merge: слияние веток double с main
|\
| * c27acd9 (double) code: изменение типа данных на double
* | b17facd code: добавление вывода минимального значения
|/
* 749a41e code: добавление вывода максимума
* 57ab0f9 code: добавление вывода частного А и В
* cbc1285 code: добавление вывода произведения A и В
* ead7cbd git: добавление игнорирование файлов
* 822e111 code: добавление вывода разности A и B
* 40c11d1 code: добавление вывода суммы A и B
* f9a4e3d code: добавления тела функции
* 7c497ed build: добавление файла проекта
* fcbb7f4 code: заготовка программы
Предпоследние два коммита находятся в другой ветке, ну а последний - слияние веток