Отчет по лабораторной работе № 2 "Система контроля версий Git"
Выполнил: Артюшина В. В.
Группа: А-01-22
Проверил:
Примечание: работа выполнялась на Windows.
1. Создала на рабочем столе каталог lab02 и запустил в нем Git Bash, приглашение:
Laptop@Artyushina MINGW64 ~/Desktop/lab02
$
2. Просмотрела файлы в рабочем каталоге командой "ls" --- пусто:
Laptop@Artyushina MINGW64 ~/Desktop/lab02
$ ls
Laptop@Artyushina MINGW64 ~/Desktop/lab02
$
3. Создала каталоги Алисы и Боба, создала каталог "project",
изучила команду "cd" в процессе:
Laptop@Artyushina MINGW64 ~/Desktop/lab02
$ mkdir alice
Laptop@Artyushina MINGW64 ~/Desktop/lab02
$ mkdir bob
Laptop@Artyushina MINGW64 ~/Desktop/lab02
$ cd alice
Laptop@Artyushina MINGW64 ~/Desktop/lab02/alice
$ mkdir project
Laptop@Artyushina MINGW64 ~/Desktop/lab02/alice
$ ls
project/
Laptop@Artyushina MINGW64 ~/Desktop/lab02/alice
$ cd project
Laptop@Artyushina MINGW64 ~/Desktop/lab02/alice/project
$ cd ..
Laptop@Artyushina MINGW64 ~/Desktop/lab02/alice
$ cd project
4. Инициализировала репозитарий:
Laptop@Artyushina MINGW64 ~/Desktop/lab02/alice/project
$ git init
Initialized empty Git repository in C:/Users/Laptop/Desktop/lab02/alice/project/.git/
Laptop@Artyushina MINGW64 ~/Desktop/lab02/alice/project (master)
$
//У меня имя ветки по умолчанию не настроено. Git создал ветку под названием master, что видно в приглашении терминала.
//Поменяю имя ветки на main командой git branch -m main:
Laptop@Artyushina MINGW64 ~/Desktop/lab02/alice/project (master)
$ git branch -m main
Laptop@Artyushina MINGW64 ~/Desktop/lab02/alice/project (main)
$
5. Настроила репозитарий Алисы, чтобы коммиты были от ее имени:
Laptop@Artyushina MINGW64 ~/Desktop/lab02/alice/project (main)
$ git config user.name 'Alice (ArtyushinaVV)'
Laptop@Artyushina MINGW64 ~/Desktop/lab02/alice/project (main)
$ git config user.email 'ArtiushinaVV@mpei.ru'
6. Просмотрела состояние рабочей копии:
Laptop@Artyushina MINGW64 ~/Desktop/lab02/alice/project (main)
$ git status
On branch main
No commits yet
Untracked files:
(use "git add <file>..." to include in what will be committed)
main.cpp
project.cbp
nothing added to commit but untracked files present (use "git add" to track)
//
On branch main - ссылка HEAD указывает на ветку main
No commits yet - говорит о том, что еще не было создано коммитов
Untracked files:
(use "git add <file>..." to include in what will be committed)
main.cpp
project.cbp - показывает не отслеживаемые файлы в хранилище git, и подсказывает как их добавить
nothing added to commit but untracked files present (use "git add" to track) - говорит о том, что нет добавленных (отслеживаемых) файлов, которые можно будет закоммитить
//Занесла под Git файл main.cpp (в набор изменений)
Laptop@Artyushina MINGW64 ~/Desktop/lab02/alice/project (main)
$ git add main.cpp
Laptop@Artyushina MINGW64 ~/Desktop/lab02/alice/project (main)
$ git status
On branch main
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)
project.cbp
//
Changes to be committed:
(use "git rm --cached <file>..." to unstage)
new file: main.cpp - Появилась строка с файлами в индексе, стоящими в очереди на коммит (так же подсказка для удаления)
//Выполнила коммит с файлом main.cpp и коротким сообщением:
Laptop@Artyushina MINGW64 ~/Desktop/lab02/alice/project (main)
$ git commit -m 'code: заготовка программы'
[main (root-commit) 8949472] code: заготовка программы
1 file changed, 9 insertions(+)
create mode 100644 main.cpp
7. Добавила файл project.cbp в индекс и сделала коммит с ним, тема — build.
Сообщение после темы по смыслу изменений - «add project file»:
Laptop@Artyushina MINGW64 ~/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
Laptop@Artyushina MINGW64 ~/Desktop/lab02/alice/project (main)
$ git commit -m 'build: add project file'
[main d331978] build: add project file
1 file changed, 38 insertions(+)
create mode 100644 project.cbp
8. Заменила тело функции main() на ввод двух чисел и посмотрела состояние репозитария:
Laptop@Artyushina MINGW64 ~/Desktop/lab02/alice/project (main)
$ git status
On branch main
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)
bin/
obj/
no changes added to commit (use "git add" and/or "git commit -a")
//После добавления в программу ввода 2х чисел появилась строка о том, что файл main.cpp был изменен (modified: main.cpp)
9. закоммитила изменения:
Laptop@Artyushina MINGW64 ~/Desktop/lab02/alice/project (main)
$ git add main.cpp
Laptop@Artyushina MINGW64 ~/Desktop/lab02/alice/project (main)
$ git commit -m "code: добавлен вывод суммы a и b в программу"
[main 88129fe] code: добавлен вывод суммы a и b в программу
1 file changed, 4 insertions(+), 2 deletions(-)
Laptop@Artyushina MINGW64 ~/Desktop/lab02/alice/project (main)
$ git add -u
Laptop@Artyushina MINGW64 ~/Desktop/lab02/alice/project (main)
$ git commit -m "code: добавлен вывод разности a и b в программу"
[main f91e880] code: добавлен вывод разности a и b в программу
1 file changed, 2 insertions(+), 1 deletion(-)
10. Занесла в список игнорируемых каталог bin:
Laptop@Artyushina MINGW64 ~/Desktop/lab02/alice/project (main)
$ git status
On branch main
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: project.cbp
Untracked files:
(use "git add <file>..." to include in what will be committed)
.gitignore
obj/
no changes added to commit (use "git add" and/or "git commit -a")
//можно видеть, что каталог bin не отображается.
//Занесла в список игнорируемых каталог obj:
Laptop@Artyushina MINGW64 ~/Desktop/lab02/alice/project (main)
$ git status
On branch main
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: project.cbp
Untracked files:
(use "git add <file>..." to include in what will be committed)
.gitignore
no changes added to commit (use "git add" and/or "git commit -a")
//Занесла под контроль версий файл .gitignore. Создала коммит с .gitignore, тема — git.
Laptop@Artyushina MINGW64 ~/Desktop/lab02/alice/project (main)
$ git add .gitignore
Laptop@Artyushina MINGW64 ~/Desktop/lab02/alice/project (main)
$ git commit -m 'git: ignore 2 files'
[main e918026] git: ignore 2 files
1 file changed, 3 insertions(+)
create mode 100644 .gitignore
11. С помощью команды git log и различных ее опций просматриваем журнал коммитов:
Laptop@Artyushina MINGW64 ~/Desktop/lab02/alice/project (main)
$ git log
commit e9180262fd84bc617f3b3e6f03ac6b5e5171c398 (HEAD -> main)
Author: Alice (ArtyushinaVV) <ArtiushinaVV@mpei.ru>
Date: Sat Mar 25 17:02:01 2023 +0300
git: ignore 2 files
commit f91e880ba8f124b920300cd8abb56b888d678bf4
Author: Alice (ArtyushinaVV) <ArtiushinaVV@mpei.ru>
Date: Sat Mar 25 16:26:58 2023 +0300
code: добавлен вывод разности a и b в программу
commit 88129fed9eb9ecbb8a814c3ba4b60e4259ff459e
Author: Alice (ArtyushinaVV) <ArtiushinaVV@mpei.ru>
Date: Sat Mar 25 16:24:32 2023 +0300
code: добавлен вывод суммы a и b в программу
commit d331978afd0359a95155a8961817e82320b3c8b6
Author: Alice (ArtyushinaVV) <ArtiushinaVV@mpei.ru>
Date: Sat Mar 25 16:20:44 2023 +0300
build: add project file
commit 89494727e0cfd75e78112f44225bfd6903a52fd9
Author: Alice (ArtyushinaVV) <ArtiushinaVV@mpei.ru>
Date: Sat Mar 25 16:19:03 2023 +0300
code: заготовка программы
// используем команду git log --stat:
Laptop@Artyushina MINGW64 ~/Desktop/lab02/alice/project (main)
$ git log --stat
commit e9180262fd84bc617f3b3e6f03ac6b5e5171c398 (HEAD -> main)
Author: Alice (ArtyushinaVV) <ArtiushinaVV@mpei.ru>
Date: Sat Mar 25 17:02:01 2023 +0300
git: ignore 2 files
.gitignore | 3 +++
1 file changed, 3 insertions(+)
commit f91e880ba8f124b920300cd8abb56b888d678bf4
Author: Alice (ArtyushinaVV) <ArtiushinaVV@mpei.ru>
Date: Sat Mar 25 16:26:58 2023 +0300
code: добавлен вывод разности a и b в программу
main.cpp | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
commit 88129fed9eb9ecbb8a814c3ba4b60e4259ff459e
Author: Alice (ArtyushinaVV) <ArtiushinaVV@mpei.ru>
Date: Sat Mar 25 16:24:32 2023 +0300
code: добавлен вывод суммы a и b в программу
main.cpp | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
commit d331978afd0359a95155a8961817e82320b3c8b6
Author: Alice (ArtyushinaVV) <ArtiushinaVV@mpei.ru>
Date: Sat Mar 25 16:20:44 2023 +0300
build: add project file
project.cbp | 38 ++++++++++++++++++++++++++++++++++++++
1 file changed, 38 insertions(+)
commit 89494727e0cfd75e78112f44225bfd6903a52fd9
Author: Alice (ArtyushinaVV) <ArtiushinaVV@mpei.ru>
Date: Sat Mar 25 16:19:03 2023 +0300
code: заготовка программы
main.cpp | 9 +++++++++
1 file changed, 9 insertions(+)
//
В последнем коммите:
commit e9180262fd84bc617f3b3e6f03ac6b5e5171c398 (HEAD -> main) - показывается хэш коммита, по которому можно потом найти этот коммит
Author: Alice (ArtyushinaVV) <ArtiushinaVV@mpei.ru> - записан автор, внесший этот коммит
Date: Sat Mar 25 17:02:01 2023 +0300 – время создания коммита
git: ignore 2 files - комментарий к коммиту
.gitignore | 3 +++ - перечисление файлов, в которых произошли изменения и кол-во измененных строчек(“+” добавленная стр., “-” удаленная стр.)
1 file changed, 3 insertions(+) - приведена статистика изменений данных файлов
//git log --oneline --decorate показывает коммиты компактно (--oneline), а также показывает ссылки, концы веток и тэги (--decorate):
Laptop@Artyushina MINGW64 ~/Desktop/lab02/alice/project (main)
$ git log --oneline --decorate
e918026 (HEAD -> main) git: ignore 2 files
f91e880 code: добавлен вывод разности a и b в программу
88129fe code: добавлен вывод суммы a и b в программу
d331978 build: add project file
8949472 code: заготовка программы
//git log --oneline --decorate --all --graph делает то же для всех веток (--all), причем коммиты отображаются в терминале в виде дерева (--graph).
Laptop@Artyushina MINGW64 ~/Desktop/lab02/alice/project (main)
$ git log --oneline --decorate --all --graph
* e918026 (HEAD -> main) git: ignore 2 files
* f91e880 code: добавлен вывод разности a и b в программу
* 88129fe code: добавлен вывод суммы a и b в программу
* d331978 build: add project file
* 8949472 code: заготовка программы
// Просмотрела информацию о коммите по измененному файлу и по теме коммита (используя команды для просмотра отдельных коммитов git log -- project.cbp и git log --grep "build:"):
Laptop@Artyushina MINGW64 ~/Desktop/lab02/alice/project (main)
$ git log --grep "build:"
commit d331978afd0359a95155a8961817e82320b3c8b6
Author: Alice (ArtyushinaVV) <ArtiushinaVV@mpei.ru>
Date: Sat Mar 25 16:20:44 2023 +0300
build: add project file
Laptop@Artyushina MINGW64 ~/Desktop/lab02/alice/project (main)
$ git log -- project.cbp
commit d331978afd0359a95155a8961817e82320b3c8b6
Author: Alice (ArtyushinaVV) <ArtiushinaVV@mpei.ru>
Date: Sat Mar 25 16:20:44 2023 +0300
build: add project file
// Тремя способами просмотрела информацию о предпоследнем коммите (результат всех способов один, поэтому в отчете не повторялся):
Laptop@Artyushina MINGW64 ~/Desktop/lab02/alice/project (main)
$ git show HEAD~1
commit f91e880ba8f124b920300cd8abb56b888d678bf4
Author: Alice (ArtyushinaVV) <ArtiushinaVV@mpei.ru>
Date: Sat Mar 25 16:26:58 2023 +0300
code: добавлен вывод разности a и b в программу
diff --git a/main.cpp b/main.cpp
index 6f95b60..eae9f61 100644
--- a/main.cpp
+++ b/main.cpp
@@ -7,5 +7,6 @@ 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';
}
//Добавиа изменения в рабочую копию и посмотрела их с помощью команды git diff:
Laptop@Artyushina MINGW64 ~/Desktop/lab02/alice/project (main)
$ git diff
warning: in the working copy of 'project.cbp', LF will be replaced by CRLF the next time Git touches it
diff --git a/main.cpp b/main.cpp
index eae9f61..6660c64 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';
}
diff --git a/project.cbp b/project.cbp
index c4697a9..17c9662 100644
--- a/project.cbp
+++ b/project.cbp
@@ -32,6 +32,7 @@
<Add option="-Wall" />
<Add option="-fexceptions" />
</Compiler>
+ <Unit filename=".gitignore" />
<Unit filename="main.cpp" />
<Extensions />
</Project>
//
diff --git a/main.cpp b/main.cpp - входные данные команды для сравнения файлов
index eae9f61..6660c64 100644
--- a/main.cpp
+++ b/main.cpp - заголовок с легендой изменения, место измененного кода и измененная функция
На следующей строке идут строки вокруг измененной части, удаленные и добавленные строки
//Просмотрела изменения между самым первым коммитом и коммитом, добавляющим вывод разности:
Laptop@Artyushina MINGW64 ~/Desktop/lab02/alice/project (main)
$ git diff 89494727e0cfd75e78112f44225bfd6903a52fd9 f91e880ba8f124b920300cd8abb56b888d678bf4
diff --git a/main.cpp b/main.cpp
index b4392ec..eae9f61 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';
}
12. Закоммитила изменения в рабочей копии (вывод произведения) и откатила этот коммит, то есть вернулась к предыдущему:
Laptop@Artyushina MINGW64 ~/Desktop/lab02/alice/project (main)
$ git add main.cpp
Laptop@Artyushina MINGW64 ~/Desktop/lab02/alice/project (main)
$ git commit -m 'code: вывод произведения'
[main cc26e40] code: вывод произведения
1 file changed, 2 insertions(+), 1 deletion(-)
Laptop@Artyushina MINGW64 ~/Desktop/lab02/alice/project (main)
$ git reset --hard HEAD~1
HEAD is now at e918026 git: ignore 2 files
//Добавила над функцией main() комментарий: // you may type whatever you want. Убрала изменения в main.cpp откатив этот файл к состоянию в последнем коммите (HEAD):
Laptop@Artyushina MINGW64 ~/Desktop/lab02/alice/project (main)
$ git checkout HEAD -- main.cpp
13.Обмен кодом через удалённое хранилище.
Для загрузки данных в репозитарий GitHub будет использоваться протокол SSH. Поэтому для обмена данными с сервером нужно сгенерировать пару из открытого и закрытого ключей:
Laptop@Artyushina MINGW64 ~/Desktop/lab02/alice/project (main)
$ ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/c/Users/Laptop/.ssh/id_rsa):
Created directory '/c/Users/Laptop/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /c/Users/Laptop/.ssh/id_rsa
Your public key has been saved in /c/Users/Laptop/.ssh/id_rsa.pub
The key fingerprint is:
SHA256:RiUsIw8T5/PpISyAaVFmXstcAGJglDlk1pmB1LK/2aU Laptop@Artyushina
The key's randomart image is:
+---[RSA 3072]----+
| .=BO.++... |
| o.=oO+o.. |
| ..o B+Xoo . |
| ..E &+o o |
| +SB.B |
| + = . |
| . . |
| |
| |
+----[SHA256]-----+
//Также после этого отображаются уникальные данные для ключа.
Поскольку в работе вводить пароль при каждом использовании ключа может быть неудобно, можно использовать программу-агент, которую достаточно запустить перед началом работы:
Laptop@Artyushina MINGW64 ~/Desktop/lab02/alice/project (main)
$ eval $(ssh-agent -s)
Agent pid 1375
Laptop@Artyushina MINGW64 ~/Desktop/lab02/alice/project (main)
$ ssh-add
Enter passphrase for /c/Users/Laptop/.ssh/id_rsa:
Identity added: /c/Users/Laptop/.ssh/id_rsa (Laptop@Artyushina)
Laptop@Artyushina MINGW64 ~/Desktop/lab02/alice/project (main)
$ cat ~/.ssh/id_rsa.pub
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQDXQoH2jGDw8CsMqG7g9d8gcuTe8RJCfersSDuiZdYuLUihRx9G113a+t4VhfzWxVwOuvOqxoXAFRVthi1BlMF74qXly7vfcGh2oHLGzRZTf4Hoxz/xBL3iWYOcv2qeRXCLmap+ywfBnDig1blWKc6OytcITJ7kunLFgYBn25zA2sLK5fubbPlt7uutuFcRiyen4Qtd7rlwS3RDXXwptH+CD8t2BGGQb34d65I/aczvhwJDfaq/Fy7+GzwDSnZIeL4KT3iPhbEzWXrNcXpJW/Az788HS2x/s7TDZBvAUbydJktWT8y7Lp0uoemLgQHp5W2i+6S8Vv+QWNI2LQAqpFK0/6TvUw2fwSbB2zfuDQwiihdUSmBbnsKkbCwqZJFk6vHR6H/u1OEQo3QOYRVjCNisdvdcJhvt1Hmi5j06lu2/jQgksxa2MKbCaWzzO4iHXZZ9Xv0EOA9GcZBvZisM/DdimfESdwec7e9bbPSuUDpu9saHDyJttWFvcC3UXfMvVHs= Laptop@Artyushina
//Затем в настройках аккаунта GitHub нужно добавить публичный ключ, который по умолчанию записывается в файл id_rsa.pub.
Теперь добавим репозитарий на который будем загружать хранилище git, и загрузим хранилище git на GitHub с помощью команды git push:
Laptop@Artyushina MINGW64 ~/Desktop/lab02/alice/project (main)
$ git remote add origin git@uit.mpei.ru:ArtiushinaVV/cs-lab02.git
Laptop@Artyushina MINGW64 ~/Desktop/lab02/alice/project (main)
$ git push -u origin main
Enumerating objects: 15, done.
Counting objects: 100% (15/15), done.
Delta compression using up to 8 threads
Compressing objects: 100% (13/13), done.
Writing objects: 100% (15/15), 2.01 KiB | 2.01 MiB/s, done.
Total 15 (delta 1), reused 0 (delta 0), pack-reused 0
remote: . Processing 1 references
remote: Processed 1 references in total
To uit.mpei.ru:ArtiushinaVV/cs-lab02.git
* [new branch] main -> main
branch 'main' set up to track 'origin/main'.
//К работе присоединяется боб. Клонировала репозитарий с помощью git clone:
Laptop@Artyushina MINGW64 ~/Desktop/lab02/bob
$ git clone git@uit.mpei.ru:ArtiushinaVV/cs-lab02.git project
Cloning into 'project'...
remote: Enumerating objects: 15, done.
remote: Counting objects: 100% (15/15), done.
remote: Compressing objects: 100% (13/13), done.
remote: Total 15 (delta 1), reused 0 (delta 0), pack-reused 0
Receiving objects: 100% (15/15), done.
Resolving deltas: 100% (1/1), done.
//Настроила хранилище Боба:
Laptop@Artyushina MINGW64 ~/Desktop/lab02/bob/project (main)
$ git config user.name 'Bob(ArtyushinaVV)'
Laptop@Artyushina MINGW64 ~/Desktop/lab02/bob/project (main)
$ git config email.name 'ArtiushinaVV@mpei.ru'
//Боб добавляет новый коммит и загружает его на GitHub:
Laptop@Artyushina MINGW64 ~/Desktop/lab02/bob/project (main)
$ git add main.cpp
Laptop@Artyushina MINGW64 ~/Desktop/lab02/bob/project (main)
$ git commit -m 'code: добавлен вывод произведения a и b'
[main 20286af] code: добавлен вывод произведения a и b
1 file changed, 2 insertions(+), 1 deletion(-)
//убедилась, что последний коммит сделан от лица Боба:
Laptop@Artyushina MINGW64 ~/Desktop/lab02/bob/project (main)
$ git show HEAD
commit 20286af16bca468f0f5ab970814adf30974a17a9 (HEAD -> main)
Author: Bob (ArtyushinaVV) <ArtiushinaVV@mpei.ru>
Date: Sun Mar 26 03:08:22 2023 +0300
code: добавлен вывод произведения a и b
diff --git a/main.cpp b/main.cpp
index 5371b30..fbd9488 100644
--- a/main.cpp
+++ b/main.cpp
@@ -8,6 +8,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;
}
Laptop@Artyushina MINGW64 ~/Desktop/lab02/bob/project (main)
$ git push
Enter passphrase for key '/c/Users/Laptop/.ssh/id_rsa':
Enumerating objects: 5, done.
Counting objects: 100% (5/5), done.
Delta compression using up to 8 threads
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 425 bytes | 425.00 KiB/s, done.
Total 3 (delta 1), reused 0 (delta 0), pack-reused 0
remote: . Processing 1 references
remote: Processed 1 references in total
To uit.mpei.ru:ArtiushinaVV/cs-lab02.git
b881d3b..20286af main -> main
//Обновила версию программы у Алисы. Для этого загрузила загрузку изменений с помощью git fetch. А затем перенесла ветку main на скачанную версию с помощью git pull:
Laptop@Artyushina MINGW64 ~/Desktop/lab02/alice/project (main)
$ git fetch
Enter passphrase for key '/c/Users/Laptop/.ssh/id_rsa':
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), 405 bytes | 57.00 KiB/s, done.
From uit.mpei.ru:ArtiushinaVV/cs-lab02
b881d3b..20286af main -> origin/main
Laptop@Artyushina MINGW64 ~/Desktop/lab02/alice/project (main)
$ git log --oneline --decorate --all --graph
* 20286af (origin/main) code: добавлен вывод произведения a и b
* b881d3b (HEAD -> main) git: ignore 2 files
* 7f94f09 code: добавлен вывод разности a и b в программу
* c22b733 code: добавлен вывод суммы a и b в программу
* 7c316e4 build: add project file
* b4828db code: заготовка программы
Laptop@Artyushina MINGW64 ~/Desktop/lab02/alice/project (main)
$ git pull --ff-only
Enter passphrase for key '/c/Users/Laptop/.ssh/id_rsa':
Updating b881d3b..20286af
Fast-forward
main.cpp | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
//Алиса вносит новое изменение, а Боб его скачивает:
Laptop@Artyushina MINGW64 ~/Desktop/lab02/alice/project (main)
$ git add -u
Laptop@Artyushina MINGW64 ~/Desktop/lab02/alice/project (main)
$ git commit -m 'code: добавлен вывод разности a и b'
[main 703b6ab] code: добавлен вывод разности a и b
1 file changed, 2 insertions(+), 1 deletion(-)
Laptop@Artyushina MINGW64 ~/Desktop/lab02/alice/project (main)
$ git show HEAD
commit 703b6ab1cb3f908e6c3a88907f365ad4c0104840 (HEAD -> main)
Author: Alice (ArtyushinaVV) <ArtiushinaVV@mpei.ru>
Date: Sun Mar 26 03:14:46 2023 +0300
code: добавлен вывод разности a и b
diff --git a/main.cpp b/main.cpp
index fbd9488..862d630 100644
--- a/main.cpp
+++ b/main.cpp
@@ -9,6 +9,7 @@ int main()
cin >> a >> b;
cout << "A + B = " << a + b << '\n'
<< "A - B = " << a - b << '\n'
- << "A * B = " << a * b << '\n';
+ << "A * B = " << a * b << '\n'
+ << "A / B = " << a / b << '\n';
return 0;
}
Laptop@Artyushina MINGW64 ~/Desktop/lab02/alice/project (main)
$ git push
Enter passphrase for key '/c/Users/Laptop/.ssh/id_rsa':
Enumerating objects: 5, done.
Counting objects: 100% (5/5), done.
Delta compression using up to 8 threads
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 441 bytes | 441.00 KiB/s, done.
Total 3 (delta 1), reused 0 (delta 0), pack-reused 0
remote: . Processing 1 references
remote: Processed 1 references in total
To uit.mpei.ru:ArtiushinaVV/cs-lab02.git
20286af..703b6ab main -> main
Laptop@Artyushina MINGW64 ~/Desktop/lab02/bob/project (main)
$ git pull
Enter passphrase for key '/c/Users/Laptop/.ssh/id_rsa':
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), 421 bytes | 38.00 KiB/s, done.
From uit.mpei.ru:ArtiushinaVV/cs-lab02
20286af..703b6ab main -> origin/main
Updating 20286af..703b6ab
Fast-forward
main.cpp | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
//Алиса и Боб добавляют в программу печать максимума и минимума соответственно, а затем пробуют загрузить изменения на репозитарий на сервере:
Laptop@Artyushina MINGW64 ~/Desktop/lab02/alice/project (main)
$ git add -u
Laptop@Artyushina MINGW64 ~/Desktop/lab02/alice/project (main)
$ git commit -m 'code: добавлен вывод максимума'
[main 6186529] code: добавлен вывод максимума
1 file changed, 2 insertions(+), 1 deletion(-)
Laptop@Artyushina MINGW64 ~/Desktop/lab02/alice/project (main)
$ git push
Enter passphrase for key '/c/Users/Laptop/.ssh/id_rsa':
Enumerating objects: 5, done.
Counting objects: 100% (5/5), done.
Delta compression using up to 8 threads
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 448 bytes | 224.00 KiB/s, done.
Total 3 (delta 1), reused 0 (delta 0), pack-reused 0
remote: . Processing 1 references
remote: Processed 1 references in total
To uit.mpei.ru:ArtiushinaVV/cs-lab02.git
703b6ab..6186529 main -> main
Laptop@Artyushina MINGW64 ~/Desktop/lab02/bob/project (main)
$ git add -u
Laptop@Artyushina MINGW64 ~/Desktop/lab02/bob/project (main)
$ git commit -m 'code: добавлен вывод минимума'
[main 3101767] code: добавлен вывод минимума
1 file changed, 2 insertions(+), 1 deletion(-)
Laptop@Artyushina MINGW64 ~/Desktop/lab02/bob/project (main)
$ git push
Enter passphrase for key '/c/Users/Laptop/.ssh/id_rsa':
To uit.mpei.ru:ArtiushinaVV/cs-lab02.git
! [rejected] main -> main (fetch first)
error: failed to push some refs to 'uit.mpei.ru:ArtiushinaVV/cs-lab02.git'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
//Однако загрузить на сервер изменения получается только у Алисы потому, что Боб затем пытается загрузить версию, основанную на более старом коммите, чем самый новый коммит в репозитарии GitHub
//Загрузила версию с сервера:
Laptop@Artyushina MINGW64 ~/Desktop/lab02/bob/project (main)
$ git fetch
Enter passphrase for key '/c/Users/Laptop/.ssh/id_rsa':
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), 428 bytes | 42.00 KiB/s, done.
From uit.mpei.ru:ArtiushinaVV/cs-lab02
703b6ab..6186529 main -> origin/main
Laptop@Artyushina MINGW64 ~/Desktop/lab02/bob/project (main)
$ git log --oneline --decorate --all --graph
* 3101767 (HEAD -> main) code: добавлен вывод минимума
| * 6186529 (origin/main, origin/HEAD) code: добавлен вывод максимума
|/
* 703b6ab code: добавлен вывод разности a и b
* 20286af code: добавлен вывод произведения a и b
* b881d3b git: ignore 2 files
* 7f94f09 code: добавлен вывод разности a и b в программу
* c22b733 code: добавлен вывод суммы a и b в программу
* 7c316e4 build: add project file
* b4828db code: заготовка программы
//Ветка main раздвоилась.
//Объединила коммиты Боба и Алисы, поместив коммит Боба выше с помощью комманды git rebase:
Laptop@Artyushina MINGW64 ~/Desktop/lab02/bob/project (main)
$ git rebase origin/main
Auto-merging main.cpp
CONFLICT (content): Merge conflict in main.cpp
error: could not apply 3101767... 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 3101767... code: добавлен вывод минимума
//Комманда завершается с ошибкой из-за конфликта в файле с кодом main.cpp. Производный файл от файла Алисы и Боба записывается в рабочую копию с помеченными метками конфликта.
Убрала метки конфликта, и доработала код так, чтобы программа компилировалась и работала. Затем загрузила изменения в индекс и продолжила операцию git rebase, с помощью флага –continue.
Laptop@Artyushina MINGW64 ~/Desktop/lab02/bob/project (main|REBASE 1/1)
$ git add -u
Laptop@Artyushina MINGW64 ~/Desktop/lab02/bob/project (main|REBASE 1/1)
$ git status
interactive rebase in progress; onto b656125
Last command done (1 command done):
pick fe3618f code: добавлен вывод минимума
No commands remaining.
You are currently rebasing branch 'main' on 'b656125'.
(all conflicts fixed: run "git rebase --continue")
Changes to be committed:
(use "git restore --staged <file>..." to unstage)
modified: project.cpp
$ git rebase --continue
[detached HEAD 7c29cf1] code: добавлен вывод минимума
1 file changed, 4 insertions(+)
Successfully rebased and updated refs/heads/main.
Laptop@Artyushina MINGW64 ~/Desktop/lab02/bob/project (main)
$ git log --oneline --decorate --all --graph
* 7c29cf1 (HEAD -> main) code: добавлен вывод минимума
* 6186529 (origin/main, origin/HEAD) code: добавлен вывод максимума
* 703b6ab code: добавлен вывод разности a и b
* 20286af code: добавлен вывод произведения a и b
* b881d3b git: ignore 2 files
* 7f94f09 code: добавлен вывод разности a и b в программу
* c22b733 code: добавлен вывод суммы a и b в программу
* 7c316e4 build: add project file
* b4828db code: заготовка программы
//Отправила изменения на сервер:
Laptop@Artyushina MINGW64 ~/Desktop/lab02/bob/project (main)
$ git push
Enter passphrase for key '/c/Users/Laptop/.ssh/id_rsa':
Enumerating objects: 5, done.
Counting objects: 100% (5/5), done.
Delta compression using up to 8 threads
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 451 bytes | 451.00 KiB/s, done.
Total 3 (delta 1), reused 0 (delta 0), pack-reused 0
remote: . Processing 1 references
remote: Processed 1 references in total
To uit.mpei.ru:ArtiushinaVV/cs-lab02.git
6186529..7c29cf1 main -> main
//В это время Алиса создаёт новую ветку (с помощью комманды git branch) для изменения типа переменных на вещественный.
Начинает она с коммита, когда добавлена печать максимума:
Laptop@Artyushina MINGW64 ~/Desktop/lab02/alice/project (main)
$ git branch double
Laptop@Artyushina MINGW64 ~/Desktop/lab02/alice/project (main)
$ git checkout double
Switched to branch 'double'
Laptop@Artyushina MINGW64 ~/Desktop/lab02/alice/project (double)
$ git add -u
Laptop@Artyushina MINGW64 ~/Desktop/lab02/alice/project (double)
$ git commit -m 'code: изменен тип переменных на вещественный'
[double 0fbb331] code: изменен тип переменных на вещественный
1 file changed, 1 insertion(+), 1 deletion(-)
// Затем переключилась на ветку main. И синхронизировала её:
Laptop@Artyushina MINGW64 ~/Desktop/lab02/alice/project (double)
$ git checkout main
Switched to branch 'main'
Your branch is up to date with 'origin/main'.
Laptop@Artyushina MINGW64 ~/Desktop/lab02/alice/project (main)
$ git pull
Enter passphrase for key '/c/Users/Laptop/.ssh/id_rsa':
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), 431 bytes | 53.00 KiB/s, done.
From uit.mpei.ru:ArtiushinaVV/cs-lab02
6186529..7c29cf1 main -> origin/main
Updating 6186529..7c29cf1
Fast-forward
main.cpp | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
Laptop@Artyushina MINGW64 ~/Desktop/lab02/alice/project (main)
$ git log --oneline --decorate --all --graph
* 0fbb331 (double) code: изменен тип переменных на вещественный
| * 7c29cf1 (HEAD -> main, origin/main) code: добавлен вывод минимума
|/
* 6186529 code: добавлен вывод максимума
* 703b6ab code: добавлен вывод разности a и b
* 20286af code: добавлен вывод произведения a и b
* b881d3b git: ignore 2 files
* 7f94f09 code: добавлен вывод разности a и b в программу
* c22b733 code: добавлен вывод суммы a и b в программу
* 7c316e4 build: add project file
* b4828db code: заготовка программы
//Получила одновременно две ветки. Объединила их с помощью комманды git merge. Внесла последние изменения и загрузила на GitHub:
Laptop@Artyushina MINGW64 ~/Desktop/lab02/alice/project (main)
$ git merge double
Auto-merging project/project.cpp
Merge made by the 'ort' strategy.
main.cpp | 2 +-p to date with 'origin/main'.
1 file changed, 1 insertion(+), 1 deletion(-)
Laptop@Artyushina MINGW64 ~/Desktop/lab02/alice/project (main)
$ git push
Enter passphrase for key '/c/Users/Laptop/.ssh/id_rsa':
Enumerating objects: 10, done.
Counting objects: 100% (10/10), done.
Delta compression using up to 8 threads
Compressing objects: 100% (6/6), done.
Writing objects: 100% (6/6), 758 bytes | 758.00 KiB/s, done.
Total 6 (delta 2), reused 0 (delta 0), pack-reused 0
remote: . Processing 1 references
remote: Processed 1 references in total
To uit.mpei.ru:ArtiushinaVV/cs-lab02.git
7c29cf1..68f8e53 main -> main
//историю всех веток репозитария:
Laptop@Artyushina MINGW64 ~/Desktop/lab02/alice/project (main)
$ git log --oneline --decorate --all --graph
* 68f8e53 (HEAD -> main, origin/main) Merge branch 'double'
|\
| * 0fbb331 (double) code: изменен тип переменных на вещественный
* | 7c29cf1 code: добавлен вывод минимума
|/
* 6186529 code: добавлен вывод максимума
* 703b6ab code: добавлен вывод разности a и b
* 20286af code: добавлен вывод произведения a и b
* b881d3b git: ignore 2 files
* 7f94f09 code: добавлен вывод разности a и b в программу
* c22b733 code: добавлен вывод суммы a и b в программу
* 7c316e4 build: add project file
* b4828db code: заготовка программы