Александр Чирка 4 недель назад
Родитель 0aded28921
Сommit 40797c2eac

@ -0,0 +1,949 @@
Отчет по лабораторной работе № 2 "Система контроля версий Git"
Выполнил: Чирка А.Р.
Группа: А-01-24
Проверил: Козлюк Д. А.
Примечание: работа выполнялась на Windows.
-------------------------------------------------------------------------
Вход в терминал и создание структуры каталогов
-------------------------------------------------------------------------
1. Создал на рабочем столе каталог lab02 и запустил в нем Git Bash, приглашение:
Lenovo@DESKTOP-NEP2E4A MINGW64 ~/Desktop/lab02
$
2. Просмотрел файлы в рабочем каталоге можно командой "ls" --- пусто:
Lenovo@DESKTOP-NEP2E4A MINGW64 ~/Desktop/lab02
$ ls
3. Создал каталоги Алисы и Боба, создал каталог "project",
изучил команду "cd" в процессе:
Lenovo@DESKTOP-NEP2E4A MINGW64 ~/Desktop/lab02
$ mkdir alice
Lenovo@DESKTOP-NEP2E4A MINGW64 ~/Desktop/lab02
$ mkdir bob
Lenovo@DESKTOP-NEP2E4A MINGW64 ~/Desktop/lab02
$ cd alice
Lenovo@DESKTOP-NEP2E4A MINGW64 ~/Desktop/lab02/alice
$ mkdir project
Lenovo@DESKTOP-NEP2E4A MINGW64 ~/Desktop/lab02/alice
$ cd project
Lenovo@DESKTOP-NEP2E4A MINGW64 ~/Desktop/lab02/alice/project
$ cd ..
Lenovo@DESKTOP-NEP2E4A MINGW64 ~/Desktop/lab02/alice
$ cd project
-------------------------------------------------------------------------
Инициализация репозитария и настройка Git
-------------------------------------------------------------------------
4. Инициализировал репозитарий:
Lenovo@DESKTOP-NEP2E4A MINGW64 ~/Desktop/lab02/alice/project
$ git init
Initialized empty Git repository in C:/Users/Lenovo/Desktop/lab02/alice/project/.git/
Lenovo@DESKTOP-NEP2E4A MINGW64 ~/Desktop/lab02/alice/project (master)
$ ls -A
.git/
5. Настроим репозитарий Алисы, чтобы коммиты были от ее имени:
Lenovo@DESKTOP-NEP2E4A MINGW64 ~/Desktop/lab02/alice/project (master)
$ git config user.name 'Alice (ChirkaAR)'
Lenovo@DESKTOP-NEP2E4A MINGW64 ~/Desktop/lab02/alice/project (master)
$ git config user.email 'ChirkaAR@mpei.ru'
-------------------------------------------------------------------------
Занесение файлов под контроль версий
-------------------------------------------------------------------------
Lenovo@DESKTOP-NEP2E4A MINGW64 ~/Desktop/lab02/alice/project (master)
$ git status
On branch master //Отображает статус ветки master
No commits yet //Еще не было сделано коммитов
Untracked files: //Файлы которые не трекаются
(use "git add <file>..." 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)
Lenovo@DESKTOP-NEP2E4A MINGW64 ~/Desktop/lab02/alice/project (master)
$ git add main.cpp
6. Еще раз посмотрел состояние рабочей копии
Lenovo@DESKTOP-NEP2E4A MINGW64 ~/Desktop/lab02/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)
bin/
obj/
project.cbp
7. Сделал первый коммит
Lenovo@DESKTOP-NEP2E4A MINGW64 ~/Desktop/lab02/alice/project (master)
$ git commit -m 'code: заготовка программы'
[master (root-commit) ea154c7] code: заготовка программы
1 file changed, 9 insertions(+)
create mode 100644 main.cpp
8. Поменял имя ветки:
Lenovo@DESKTOP-NEP2E4A MINGW64 ~/Desktop/lab02/alice/project (master)
$ git branch -m main
-------------------------------------------------------------------------
Составление сообщений к коммитам
-------------------------------------------------------------------------
9. Добавил файл project.cbp в индекс и сделал коммит с ним
Lenovo@DESKTOP-NEP2E4A 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
Lenovo@DESKTOP-NEP2E4A MINGW64 ~/Desktop/lab02/alice/project (main)
$ git commit -m 'build: add project file'
[main 20710a4] build: add project file
1 file changed, 40 insertions(+)
create mode 100644 project.cbp
Lenovo@DESKTOP-NEP2E4A 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")
Lenovo@DESKTOP-NEP2E4A MINGW64 ~/Desktop/lab02/alice/project (main)
$ git add main.cpp
Lenovo@DESKTOP-NEP2E4A MINGW64 ~/Desktop/lab02/alice/project (main)
$ git commit -m 'code: add sum'
[main a475681] code: add sum
1 file changed, 4 insertions(+), 2 deletions(-)
Lenovo@DESKTOP-NEP2E4A MINGW64 ~/Desktop/lab02/alice/project (main)
$ git add -u
Lenovo@DESKTOP-NEP2E4A MINGW64 ~/Desktop/lab02/alice/project (main)
$ git commit -m 'code: add difference'
[main b5a62d1] code: add difference
1 file changed, 2 insertions(+), 1 deletion(-)
-------------------------------------------------------------------------
Игнорирование файлов
-------------------------------------------------------------------------
Lenovo@DESKTOP-NEP2E4A MINGW64 ~/Desktop/lab02/alice/project (main)
$ git status
On branch main
Untracked files:
(use "git add <file>..." to include in what will be committed)
.gitignore
obj/
project.depend
nothing added to commit but untracked files present (use "git add" to track)
Lenovo@DESKTOP-NEP2E4A MINGW64 ~/Desktop/lab02/alice/project (main)
$ git status
On branch main
Untracked files:
(use "git add <file>..." to include in what will be committed)
.gitignore
project.depend
nothing added to commit but untracked files present (use "git add" to track)
Lenovo@DESKTOP-NEP2E4A MINGW64 ~/Desktop/lab02/alice/project (main)
$ git add .gitignore
10. Создал коммит с .gitignore, тема — git.
Lenovo@DESKTOP-NEP2E4A MINGW64 ~/Desktop/lab02/alice/project (main)
$ git commit -m 'build: git'
[main edcde68] build: git
1 file changed, 3 insertions(+)
create mode 100644 .gitignore
-------------------------------------------------------------------------
Просмотр истории
-------------------------------------------------------------------------
Lenovo@DESKTOP-NEP2E4A MINGW64 ~/Desktop/lab02/alice/project (main)
$ git log
commit edcde6834f3820e782cd531a89b71703a1eb72af (HEAD -> main)
Author: Alice (ChirkaAR) <ChirkaAR@mpei.ru>
Date: Mon Mar 3 00:45:22 2025 +0300
build: git
commit b5a62d1b8615bd473334d82364c4ed943447971b
Author: Alice (ChirkaAR) <ChirkaAR@mpei.ru>
Date: Mon Mar 3 00:37:42 2025 +0300
code: add difference
commit a4756818091b432fa19a272cda397dba1c5ce95c
Author: Alice (ChirkaAR) <ChirkaAR@mpei.ru>
Date: Mon Mar 3 00:36:30 2025 +0300
code: add sum
commit 20710a4a352e308df790462b458ac143ae43ca57
Author: Alice (ChirkaAR) <ChirkaAR@mpei.ru>
Date: Sun Mar 2 22:59:04 2025 +0300
build: add project file
commit ea154c7dcdb92c65b323c1476a0b8ad5e92502ab
Author: Alice (ChirkaAR) <ChirkaAR@mpei.ru>
Date: Sun Mar 2 22:54:27 2025 +0300
code: заготовка программы
Lenovo@DESKTOP-NEP2E4A MINGW64 ~/Desktop/lab02/alice/project (main)
$ git log --stat
commit edcde6834f3820e782cd531a89b71703a1eb72af (HEAD -> main)
Author: Alice (ChirkaAR) <ChirkaAR@mpei.ru>
Date: Mon Mar 3 00:45:22 2025 +0300
build: git
.gitignore | 3 +++
1 file changed, 3 insertions(+)
commit b5a62d1b8615bd473334d82364c4ed943447971b
Author: Alice (ChirkaAR) <ChirkaAR@mpei.ru>
Date: Mon Mar 3 00:37:42 2025 +0300
code: add difference
main.cpp | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
commit a4756818091b432fa19a272cda397dba1c5ce95c
Author: Alice (ChirkaAR) <ChirkaAR@mpei.ru>
Date: Mon Mar 3 00:36:30 2025 +0300
code: add sum
main.cpp | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
commit 20710a4a352e308df790462b458ac143ae43ca57
Author: Alice (ChirkaAR) <ChirkaAR@mpei.ru>
Date: Sun Mar 2 22:59:04 2025 +0300
build: add project file
project.cbp | 40 ++++++++++++++++++++++++++++++++++++++++
1 file changed, 40 insertions(+)
commit ea154c7dcdb92c65b323c1476a0b8ad5e92502ab
Author: Alice (ChirkaAR) <ChirkaAR@mpei.ru>
Date: Sun Mar 2 22:54:27 2025 +0300
code: заготовка программы
main.cpp | 9 +++++++++
1 file changed, 9 insertions(+)
Lenovo@DESKTOP-NEP2E4A MINGW64 ~/Desktop/lab02/alice/project (main)
$ git log --oneline --decorate
edcde68 (HEAD -> main) build: git
b5a62d1 code: add difference
a475681 code: add sum
20710a4 build: add project file
ea154c7 code: заготовка программы
Lenovo@DESKTOP-NEP2E4A MINGW64 ~/Desktop/lab02/alice/project (main)
$ git log --oneline --decorate --all --graph
* edcde68 (HEAD -> main) build: git
* b5a62d1 code: add difference
* a475681 code: add sum
* 20710a4 build: add project file
* ea154c7 code: заготовка программы
11. Нашел коммиты по теме build:
Lenovo@DESKTOP-NEP2E4A MINGW64 ~/Desktop/lab02/alice/project (main)
$ git log --grep "build:"
commit edcde6834f3820e782cd531a89b71703a1eb72af (HEAD -> main)
Author: Alice (ChirkaAR) <ChirkaAR@mpei.ru>
Date: Mon Mar 3 00:45:22 2025 +0300
build: git
commit 20710a4a352e308df790462b458ac143ae43ca57
Author: Alice (ChirkaAR) <ChirkaAR@mpei.ru>
Date: Sun Mar 2 22:59:04 2025 +0300
build: add project file
12. Нашел коммиты, затрагивающие project.cbp:
Lenovo@DESKTOP-NEP2E4A MINGW64 ~/Desktop/lab02/alice/project (main)
$ git log -- project.cbp
commit 20710a4a352e308df790462b458ac143ae43ca57
Author: Alice (ChirkaAR) <ChirkaAR@mpei.ru>
Date: Sun Mar 2 22:59:04 2025 +0300
build: add project file
-------------------------------------------------------------------------
Просмотр коммитов
-------------------------------------------------------------------------
13. Просмотрел предпоследний коммит:
Lenovo@DESKTOP-NEP2E4A MINGW64 ~/Desktop/lab02/alice/project (main)
$ git show HEAD~1
commit b5a62d1b8615bd473334d82364c4ed943447971b
Author: Alice (ChirkaAR) <ChirkaAR@mpei.ru>
Date: Mon Mar 3 00:37:42 2025 +0300
code: add difference
diff --git a/main.cpp b/main.cpp
index 4364dbc..8435233 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';
}
-------------------------------------------------------------------------
Просмотр изменений
-------------------------------------------------------------------------
14. Просмотрел изменения в рабочей копии:
Lenovo@DESKTOP-NEP2E4A MINGW64 ~/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';
}
Lenovo@DESKTOP-NEP2E4A MINGW64 ~/Desktop/lab02/alice/project (main)
$ git diff HEAD~2
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..d85abef
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,3 @@
+/bin
+/obj
+/*.layout
diff --git a/main.cpp b/main.cpp
index 4364dbc..f372c78 100644
--- a/main.cpp
+++ b/main.cpp
@@ -7,5 +7,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'
+ << "A * B = " << a * b << '\n';
}
Lenovo@DESKTOP-NEP2E4A MINGW64 ~/Desktop/lab02/alice/project (main)
$ git diff HEAD~2 HEAD
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..d85abef
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,3 @@
+/bin
+/obj
+/*.layout
diff --git a/main.cpp b/main.cpp
index 4364dbc..8435233 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';
}
15. Просмотрел изменения между самым первым коммитом и коммитом, добавляющим вывод разности:
Lenovo@DESKTOP-NEP2E4A MINGW64 ~/Desktop/lab02/alice/project (main)
$ git diff ea154c7 b5a62d1
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';
}
diff --git a/project.cbp b/project.cbp
new file mode 100644
index 0000000..99bb702
--- /dev/null
+++ b/project.cbp
@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
+<CodeBlocks_project_file>
+ <FileVersion major="1" minor="6" />
+ <Project>
+ <Option title="project" />
+ <Option pch_mode="2" />
+ <Option compiler="gcc" />
+ <Build>
+ <Target title="Debug">
+ <Option output="bin/Debug/project" prefix_auto="1" extension_auto="1" />
+ <Option object_output="obj/Debug/" />
+ <Option type="1" />
+ <Option compiler="gcc" />
+ <Compiler>
+ <Add option="-g" />
+ </Compiler>
+ </Target>
+ <Target title="Release">
+ <Option output="bin/Release/project" prefix_auto="1" extension_auto="1" />
+ <Option object_output="obj/Release/" />
+ <Option type="1" />
+ <Option compiler="gcc" />
+ <Compiler>
+ <Add option="-O2" />
-------------------------------------------------------------------------
Откат изменений
-------------------------------------------------------------------------
Lenovo@DESKTOP-NEP2E4A MINGW64 ~/Desktop/lab02/alice/project (main)
$ git add -u
warning: in the working copy of 'project.cbp', LF will be replaced by CRLF the next time Git touches it
16. Закоммител изменения в рабочей копии (вывод произведения):
Lenovo@DESKTOP-NEP2E4A MINGW64 ~/Desktop/lab02/alice/project (main)
$ git commit -m 'code: add product'
[main 2da9f89] code: add product
2 files changed, 3 insertions(+), 1 deletion(-)
Lenovo@DESKTOP-NEP2E4A MINGW64 ~/Desktop/lab02/alice/project (main)
$ git reset --hard HEAD~1
HEAD is now at edcde68 build: git
Lenovo@DESKTOP-NEP2E4A MINGW64 ~/Desktop/lab02/alice/project (main)
$ git checkout HEAD -- main.cpp
-------------------------------------------------------------------------
Обмен кодом через удаленное хранилище
-------------------------------------------------------------------------
Lenovo@DESKTOP-NEP2E4A MINGW64 ~/Desktop/lab02/alice/project (main)
$ ssh-keygen
Generating public/private ed25519 key pair.
Enter file in which to save the key (/c/Users/Lenovo/.ssh/id_ed25519):
Created directory '/c/Users/Lenovo/.ssh'.
Enter passphrase for "/c/Users/Lenovo/.ssh/id_ed25519" (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /c/Users/Lenovo/.ssh/id_ed25519
Your public key has been saved in /c/Users/Lenovo/.ssh/id_ed25519.pub
The key fingerprint is:
SHA256:dAdkf6tbLt2itUAgAPWw3dDteFpSBXkmScibKnY1LCY Lenovo@DESKTOP-NEP2E4A
The key's randomart image is:
+--[ED25519 256]--+
| .o+ .+++o=. |
| * ++o* o |
| . =.+*o+. |
| E.ooOo+. . |
| oS+ *. . |
| o o .. . |
| . o o.o. |
| .*o..|
| ooo. |
+----[SHA256]-----+
Lenovo@DESKTOP-NEP2E4A MINGW64 ~/Desktop/lab02/alice/project (main)
$ eval $(ssh-agent -s)
Agent pid 704
Lenovo@DESKTOP-NEP2E4A MINGW64 ~/Desktop/lab02/alice/project (main)
$ ssh-add
Identity added: /c/Users/Lenovo/.ssh/id_ed25519 (Lenovo@DESKTOP-NEP2E4A)
Lenovo@DESKTOP-NEP2E4A MINGW64 ~/Desktop/lab02/alice/project (main)
$ cat ~/.ssh/id_ed25519.pub
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAINvvgIWP3cp8/oKPSfgjVaU6sutW5qn+PoBxnebCgfaB Lenovo@DESKTOP-NEP2E4A
-------------------------------------------------------------------------
Отправка проекта на сервер
-------------------------------------------------------------------------
Lenovo@DESKTOP-NEP2E4A MINGW64 ~/Desktop/lab02/alice/project (main)
$ touch README.md
Lenovo@DESKTOP-NEP2E4A MINGW64 ~/Desktop/lab02/alice/project (main)
$ git init
Reinitialized existing Git repository in C:/Users/Lenovo/Desktop/lab02/alice/project/.git/
Lenovo@DESKTOP-NEP2E4A MINGW64 ~/Desktop/lab02/alice/project (main)
$ git checkout -b main
fatal: a branch named 'main' already exists
Lenovo@DESKTOP-NEP2E4A MINGW64 ~/Desktop/lab02/alice/project (main)
$ git add README.md
Lenovo@DESKTOP-NEP2E4A MINGW64 ~/Desktop/lab02/alice/project (main)
$ git commit -m "first commit"
[main f94e9ad] first commit
1 file changed, 0 insertions(+), 0 deletions(-)
create mode 100644 README.md
Lenovo@DESKTOP-NEP2E4A MINGW64 ~/Desktop/lab02/alice/project (main)
$ git remote add origin http://uit.mpei.ru/git/ChirkaAR/cs-lab02.git
Lenovo@DESKTOP-NEP2E4A MINGW64 ~/Desktop/lab02/alice/project (main)
$ git push -u origin main
warning: use of unencrypted HTTP remote URLs is not recommended; see https://aka.ms/gcm/unsaferemotes for more information.
Enumerating objects: 18, done.
Counting objects: 100% (18/18), done.
Delta compression using up to 20 threads
Compressing objects: 100% (15/15), done.
Writing objects: 100% (18/18), 2.09 KiB | 1.04 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/ChirkaAR/cs-lab02.git
* [new branch] main -> main
branch 'main' set up to track 'origin/main'.
-------------------------------------------------------------------------
Получение проекта с сервера
-------------------------------------------------------------------------
Lenovo@DESKTOP-NEP2E4A MINGW64 ~/Desktop/lab02/bob
$ git clone http://uit.mpei.ru/git/ChirkaAR/cs-lab02.git project
Cloning into 'project'...
remote: Enumerating objects: 18, done.
remote: Counting objects: 100% (18/18), done.
remote: Compressing objects: 100% (15/15), 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.
Lenovo@DESKTOP-NEP2E4A MINGW64 ~/Desktop/lab02/bob
$ cd project
17. «На машине Боба» настроил Git (git config):
Lenovo@DESKTOP-NEP2E4A MINGW64 ~/Desktop/lab02/bob/project (main)
$ git config user.name 'Bob (ChirkaAR)'
Lenovo@DESKTOP-NEP2E4A MINGW64 ~/Desktop/lab02/bob/project (main)
$ git config user.email 'ChirkaAR@mpei.ru'
-------------------------------------------------------------------------
Совместная работа над проектом без конфликтов и правок
-------------------------------------------------------------------------
Lenovo@DESKTOP-NEP2E4A MINGW64 ~/Desktop/lab02/bob/project (main)
$ git add -u
Lenovo@DESKTOP-NEP2E4A MINGW64 ~/Desktop/lab02/bob/project (main)
$ git commit -m 'code: add product'
[main 1c7685c] code: add product
1 file changed, 2 insertions(+), 1 deletion(-)
Lenovo@DESKTOP-NEP2E4A MINGW64 ~/Desktop/lab02/bob/project (main)
$ git show HEAD
commit 1c7685cb020e59c216ca80abfae7753c709da4c4 (HEAD -> main)
Author: Bob (ChirkaAR) <ChirkaAR@mpei.ru>
Date: Sun Mar 30 23:11:43 2025 +0300
code: add product
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';
}
Lenovo@DESKTOP-NEP2E4A MINGW64 ~/Desktop/lab02/bob/project (main)
$ git push
Enumerating objects: 5, done.
Counting objects: 100% (5/5), done.
Delta compression using up to 20 threads
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 322 bytes | 322.00 KiB/s, done.
Total 3 (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/ChirkaAR/cs-lab02.git
f94e9ad..1c7685c main -> main
18. Загрузка изменений на машине Алисы:
Lenovo@DESKTOP-NEP2E4A MINGW64 ~/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 2), reused 0 (delta 0), pack-reused 0
Unpacking objects: 100% (3/3), 302 bytes | 27.00 KiB/s, done.
From http://uit.mpei.ru/git/ChirkaAR/cs-lab02
f94e9ad..1c7685c main -> origin/main
Lenovo@DESKTOP-NEP2E4A MINGW64 ~/Desktop/lab02/alice/project (main)
$ git log --oneline --decorate --all --graph
* 1c7685c (origin/main, origin/HEAD) code: add product
* f94e9ad (HEAD -> main) first commit
* edcde68 build: git
* b5a62d1 code: add difference
* a475681 code: add sum
* 20710a4 build: add project file
* ea154c7 code: заготовка программы
Lenovo@DESKTOP-NEP2E4A MINGW64 ~/Desktop/lab02/alice/project (main)
$ git pull --ff-only
Updating f94e9ad..1c7685c
Fast-forward
main.cpp | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
Lenovo@DESKTOP-NEP2E4A MINGW64 ~/Desktop/lab02/alice/project (main)
$ git log --oneline --decorate --all --graph
* 1c7685c (HEAD -> main, origin/main, origin/HEAD) code: add product
* f94e9ad first commit
* edcde68 build: git
* b5a62d1 code: add difference
* a475681 code: add sum
* 20710a4 build: add project file
* ea154c7 code: заготовка программы
19. Добавление деления от имени Алисы:
Lenovo@DESKTOP-NEP2E4A MINGW64 ~/Desktop/lab02/alice/project (main)
$ git add -u
Lenovo@DESKTOP-NEP2E4A MINGW64 ~/Desktop/lab02/alice/project (main)
$ git commit -m 'code: add division'
[main 192b2ca] code: add division
1 file changed, 2 insertions(+), 1 deletion(-)
Lenovo@DESKTOP-NEP2E4A MINGW64 ~/Desktop/lab02/alice/project (main)
$ git show HEAD
commit 192b2cab8bbfedf0890f9ff04ea59927e1808712 (HEAD -> main)
Author: Alice (ChirkaAR) <ChirkaAR@mpei.ru>
Date: Sun Mar 30 23:20:38 2025 +0300
code: add division
diff --git a/main.cpp b/main.cpp
index f372c78..38bc977 100644
--- a/main.cpp
+++ b/main.cpp
@@ -9,5 +9,6 @@ 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';
}
Lenovo@DESKTOP-NEP2E4A MINGW64 ~/Desktop/lab02/alice/project (main)
$ git push
Enumerating objects: 5, done.
Counting objects: 100% (5/5), done.
Delta compression using up to 20 threads
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 319 bytes | 319.00 KiB/s, done.
Total 3 (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/ChirkaAR/cs-lab02.git
1c7685c..192b2ca main -> main
Lenovo@DESKTOP-NEP2E4A MINGW64 ~/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 2), reused 0 (delta 0), pack-reused 0
Unpacking objects: 100% (3/3), 299 bytes | 21.00 KiB/s, done.
From http://uit.mpei.ru/git/ChirkaAR/cs-lab02
1c7685c..192b2ca main -> origin/main
Lenovo@DESKTOP-NEP2E4A MINGW64 ~/Desktop/lab02/bob/project (main)
$ git log --oneline --decorate --all --graph
* 192b2ca (origin/main, origin/HEAD) code: add division
* 1c7685c (HEAD -> main) code: add product
* f94e9ad first commit
* edcde68 build: git
* b5a62d1 code: add difference
* a475681 code: add sum
* 20710a4 build: add project file
* ea154c7 code: заготовка программы
Lenovo@DESKTOP-NEP2E4A MINGW64 ~/Desktop/lab02/bob/project (main)
$ git pull --ff-only
Updating 1c7685c..192b2ca
Fast-forward
main.cpp | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
Lenovo@DESKTOP-NEP2E4A MINGW64 ~/Desktop/lab02/bob/project (main)
$ git log --oneline --decorate --all --graph
* 192b2ca (HEAD -> main, origin/main, origin/HEAD) code: add division
* 1c7685c code: add product
* f94e9ad first commit
* edcde68 build: git
* b5a62d1 code: add difference
* a475681 code: add sum
* 20710a4 build: add project file
* ea154c7 code: заготовка программы
Lenovo@DESKTOP-NEP2E4A MINGW64 ~/Desktop/lab02/bob/project (main)
$
-------------------------------------------------------------------------
Разрешение конфликтов правок при совместной работе
-------------------------------------------------------------------------
20. «На машине Алисы» дополнил программу печатью максимума, сделайте коммит и отправьте его на сервер:
Lenovo@DESKTOP-NEP2E4A MINGW64 ~/Desktop/lab02/alice/project (main)
$ git add -u
Lenovo@DESKTOP-NEP2E4A MINGW64 ~/Desktop/lab02/alice/project (main)
$ git commit -m 'code: add max'
[main 8cb6ab8] code: add max
1 file changed, 2 insertions(+), 1 deletion(-)
Lenovo@DESKTOP-NEP2E4A MINGW64 ~/Desktop/lab02/alice/project (main)
$ git push
Enumerating objects: 5, done.
Counting objects: 100% (5/5), done.
Delta compression using up to 20 threads
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 334 bytes | 334.00 KiB/s, done.
Total 3 (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/ChirkaAR/cs-lab02.git
192b2ca..8cb6ab8 main -> main
Lenovo@DESKTOP-NEP2E4A MINGW64 ~/Desktop/lab02/alice/project (main)
$
21. «От лица Боба» загрузил коммиты из удаленного хранилища и отобразите историю всех веток:
Lenovo@DESKTOP-NEP2E4A MINGW64 ~/Desktop/lab02/bob/project (main)
$ git add -u
Lenovo@DESKTOP-NEP2E4A MINGW64 ~/Desktop/lab02/bob/project (main)
$ git commit -m 'code: add min'
[main 2116dec] code: add min
1 file changed, 2 insertions(+), 1 deletion(-)
Lenovo@DESKTOP-NEP2E4A MINGW64 ~/Desktop/lab02/bob/project (main)
$ git push
To http://uit.mpei.ru/git/ChirkaAR/cs-lab02.git
! [rejected] main -> main (fetch first)
error: failed to push some refs to 'http://uit.mpei.ru/git/ChirkaAR/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.
Lenovo@DESKTOP-NEP2E4A MINGW64 ~/Desktop/lab02/bob/project (main)
$
/* Выполнил отображение всех веток и сделал "git rebase --continue", после этого появилось "окно"
/* с большим количеством текста, которое не закрывалось, после закрытия терминала и повторного выполнения
/* команды выдало сообщение :Successfully rebased and updated refs/heads/main"
Lenovo@DESKTOP-NEP2E4A MINGW64 ~/Desktop/lab02/bob/project (main|REBASE 1/1)
$ git add main.cpp
Lenovo@DESKTOP-NEP2E4A MINGW64 ~/Desktop/lab02/bob/project (main|REBASE 1/1)
$ git rebase --continue
Successfully rebased and updated refs/heads/main.
Lenovo@DESKTOP-NEP2E4A MINGW64 ~/Desktop/lab02/bob/project (main)
$ git log --oneline --decorate --all --graph
* e11d953 (HEAD -> main) code: add min
* 8cb6ab8 (origin/main, origin/HEAD) code: add max
* 192b2ca code: add division
* 1c7685c code: add product
* f94e9ad first commit
* edcde68 build: git
* b5a62d1 code: add difference
* a475681 code: add sum
* 20710a4 build: add project file
* ea154c7 code: заготовка программы
Lenovo@DESKTOP-NEP2E4A MINGW64 ~/Desktop/lab02/bob/project (main)
$ git push
Enumerating objects: 5, done.
Counting objects: 100% (5/5), done.
Delta compression using up to 20 threads
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 335 bytes | 335.00 KiB/s, done.
Total 3 (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/ChirkaAR/cs-lab02.git
8cb6ab8..e11d953 main -> main
-------------------------------------------------------------------------
Использование веток
-------------------------------------------------------------------------
Lenovo@DESKTOP-NEP2E4A MINGW64 ~/Desktop/lab02/alice/project (main)
$ git branch double
Lenovo@DESKTOP-NEP2E4A MINGW64 ~/Desktop/lab02/alice/project (main)
$ git checkout double
Switched to branch 'double'
Lenovo@DESKTOP-NEP2E4A MINGW64 ~/Desktop/lab02/alice/project (double)
$ git add -u
Lenovo@DESKTOP-NEP2E4A MINGW64 ~/Desktop/lab02/alice/project (double)
$ git commit -m 'code: replacing int with double'
[double 4f1d9e8] code: replacing int with double
1 file changed, 1 insertion(+), 1 deletion(-)
Lenovo@DESKTOP-NEP2E4A MINGW64 ~/Desktop/lab02/alice/project (double)
$ git checkout main
Switched to branch 'main'
Your branch is up to date with 'origin/main'.
Lenovo@DESKTOP-NEP2E4A MINGW64 ~/Desktop/lab02/alice/project (main)
$
Lenovo@DESKTOP-NEP2E4A MINGW64 ~/Desktop/lab02/alice/project (main|MERGING)
$ git merge double
fatal: You have not concluded your merge (MERGE_HEAD exists).
Please, commit your changes before you merge.
Lenovo@DESKTOP-NEP2E4A MINGW64 ~/Desktop/lab02/alice/project (main|MERGING)
$ git merge double
fatal: You have not concluded your merge (MERGE_HEAD exists).
Please, commit your changes before you merge.
Lenovo@DESKTOP-NEP2E4A MINGW64 ~/Desktop/lab02/alice/project (main|MERGING)
$ git commit -m 'code: replacing int with double'
[main 0aded28] code: replacing int with double
Lenovo@DESKTOP-NEP2E4A MINGW64 ~/Desktop/lab02/alice/project (main)
$ git push
Enumerating objects: 10, done.
Counting objects: 100% (10/10), done.
Delta compression using up to 20 threads
Compressing objects: 100% (6/6), done.
Writing objects: 100% (6/6), 591 bytes | 591.00 KiB/s, done.
Total 6 (delta 4), 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/ChirkaAR/cs-lab02.git
e11d953..0aded28 main -> main
Lenovo@DESKTOP-NEP2E4A MINGW64 ~/Desktop/lab02/alice/project (main)
$ git merge double
Already up to date.
Lenovo@DESKTOP-NEP2E4A MINGW64 ~/Desktop/lab02/alice/project (main)
$ git log --oneline --decorate --all --graph
* 0aded28 (HEAD -> main, origin/main, origin/HEAD) code: replacing int with double
|\
| * 4f1d9e8 (double) code: replacing int with double
* | e11d953 code: add min
|/
* 8cb6ab8 code: add max
* 192b2ca code: add division
* 1c7685c code: add product
* f94e9ad first commit
* edcde68 build: git
* b5a62d1 code: add difference
* a475681 code: add sum
* 20710a4 build: add project file
* ea154c7 code: заготовка программы
Lenovo@DESKTOP-NEP2E4A MINGW64 ~/Desktop/lab02/alice/project (main)
$
Загрузка…
Отмена
Сохранить