Создал(а) 'отчет.txt'

main
TwixAlex 3 недель назад
Родитель a19d1a71fe
Сommit 3bff952a04

@ -0,0 +1,645 @@
Создание директории "alice" в текущей папке
```
taa41@alextwix MINGW64 ~/Desktop/lab2
$ mkdir alice
```
Создание директории "bob" в текущей папке
```
taa41@alextwix MINGW64 ~/Desktop/lab2
$ mkdir bob
```
Переход в директорию "alice"
```
taa41@alextwix MINGW64 ~/Desktop/lab2
$ cd alice
```
Создание поддиректории "project" внутри "alice"
```
taa41@alextwix MINGW64 ~/Desktop/lab2/alice
$ mkdir project
```
Переход в директорию "project"
```
taa41@alextwix MINGW64 ~/Desktop/lab2/alice
$ cd project
```
Возврат на уровень выше (в директорию "alice")
```
taa41@alextwix MINGW64 ~/Desktop/lab2/alice/project
$ cd ..
```
Снова переход в директорию "project"
```
taa41@alextwix MINGW64 ~/Desktop/lab2/alice
$ cd project
```
Инициализация пустого git-репозитория в текущей директории
```
taa41@alextwix MINGW64 ~/Desktop/lab2/alice/project
$ git init
Initialized empty Git repository in C:/Users/taa41/Desktop/lab2/alice/project/.git/
```
Настройка имени пользователя для git
```
taa41@alextwix MINGW64 ~/Desktop/lab2/alice/project (main)
$ git config user.name 'Alice (TupikovAA)'
```
Настройка email пользователя для git
```
taa41@alextwix MINGW64 ~/Desktop/lab2/alice/project (main)
$ git config user.email 'taa4178@gmail.com'
```
Проверка состояния репозитория
```
taa41@alextwix MINGW64 ~/Desktop/lab2/alice/project (main)
$ git status
On branch main
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)
```
Добавление файла main.cpp в индекс
```
taa41@alextwix MINGW64 ~/Desktop/lab2/alice/project (main)
$ git add main.cpp
```
Создание коммита с сообщением
```
taa41@alextwix MINGW64 ~/Desktop/lab2/alice/project (main)
$ git commit -m 'code: заготовка программы'
[main (root-commit) 88d573e] code: заготовка программы
1 file changed, 9 insertions(+)
create mode 100644 main.cpp
```
Добавление файла project.cbp в индекс
```
taa41@alextwix MINGW64 ~/Desktop/lab2/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
```
Проверка состояния репозитория
```
taa41@alextwix MINGW64 ~/Desktop/lab2/alice/project (main)
$ git status
On branch main
Changes to be committed:
(use "git restore --staged <file>..." to unstage)
new file: project.cbp
Untracked files:
(use "git add <file>..." to include in what will be committed)
.gitignore
bin/
obj/
```
Создание коммита для файла project.cbp
```
taa41@alextwix MINGW64 ~/Desktop/lab2/alice/project (main)
$ git commit -m 'build: add project file'
[main 08119ab] build: add project file
1 file changed, 40 insertions(+)
create mode 100644 project.cbp
```
Добавление изменений в main.cpp и создание коммита
```
taa41@alextwix MINGW64 ~/Desktop/lab2/alice/project (main)
$ git add main.cpp
$ git commit -m 'code: add input'
[main a4aeeb1] code: add input
1 file changed, 4 insertions(+), 2 deletions(-)
```
Добавление всех отслеживаемых изменений и создание коммита
```
taa41@alextwix MINGW64 ~/Desktop/lab2/alice/project (main)
$ git add -u
$ git commit -m 'code: add sum'
[main 2690843] code: add sum
1 file changed, 1 insertion(+), 1 deletion(-)
```
Создание коммита для всех измененных файлов
```
taa41@alextwix MINGW64 ~/Desktop/lab2/alice/project (main)
$ git commit -a -m 'code: add diff'
[main 53966cb] code: add diff
1 file changed, 1 insertion(+), 1 deletion(-)
```
Добавление файла .gitignore и создание коммита
```
taa41@alextwix MINGW64 ~/Desktop/lab2/alice/project (main)
$ git add .gitignore
$ git commit -m 'git: add .gitignore'
[main 072f731] git: add .gitignore
1 file changed, 3 insertions(+)
create mode 100644 .gitignore
```
Просмотр истории коммитов с статистикой изменений
```
taa41@alextwix MINGW64 ~/Desktop/lab2/alice/project (main)
$ git log --stat
commit 072f731803921b240d1df4511ae97e6cbb46a885 (HEAD -> main)
Author: Alice (TupikovAA) <taa4178@gmail.com>
Date: Thu Apr 3 22:28:03 2025 +0300
git: add .gitignore
.gitignore | 3 +++
1 file changed, 3 insertions(+)
commit 53966cbdb24ede979a2e3ea8e06272a95c928dd6
Author: Alice (TupikovAA) <taa4178@gmail.com>
Date: Thu Apr 3 22:25:33 2025 +0300
code: add diff
main.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
commit 2690843691ed9f729400a88247b5bea6c6d566b9
Author: Alice (TupikovAA) <taa4178@gmail.com>
Date: Thu Apr 3 22:24:03 2025 +0300
code: add sum
main.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
commit a4aeeb11b1e722da45a0d08cf0e366f68a16d81b
Author: Alice (TupikovAA) <taa4178@gmail.com>
Date: Thu Apr 3 22:19:49 2025 +0300
code: add input
main.cpp | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
commit 08119ab107dc03debee74f7d7cb4f170bd9ecfac
Author: Alice (TupikovAA) <taa4178@gmail.com>
Date: Thu Apr 3 22:18:29 2025 +0300
build: add project file
project.cbp | 40 ++++++++++++++++++++++++++++++++++++++++
1 file changed, 40 insertions(+)
commit 88d573e198d29ba42b8fce16c0685a9648080c92
Author: Alice (TupikovAA) <taa4178@gmail.com>
Date: Thu Apr 3 22:16:23 2025 +0300
code: заготовка программы
main.cpp | 9 +++++++++
1 file changed, 9 insertions(+)
```
Просмотр сокращенной истории коммитов
```
taa41@alextwix MINGW64 ~/Desktop/lab2/alice/project (main)
$ git log --oneline --decorate
072f731 (HEAD -> main) git: add .gitignore
53966cb code: add diff
2690843 code: add sum
a4aeeb1 code: add input
08119ab build: add project file
88d573e code: заготовка программы
```
Просмотр истории коммитов в виде графа
```
taa41@alextwix MINGW64 ~/Desktop/lab2/alice/project (main)
$ git log --oneline --decorate --all --graph
* 072f731 (HEAD -> main) git: add .gitignore
* 53966cb code: add diff
* 2690843 code: add sum
* a4aeeb1 code: add input
* 08119ab build: add project file
* 88d573e code: заготовка программы
```
Поиск коммитов по сообщению
```
taa41@alextwix MINGW64 ~/Desktop/lab2/alice/project (main)
$ git log --grep 'build:'
commit 08119ab107dc03debee74f7d7cb4f170bd9ecfac
Author: Alice (TupikovAA) <taa4178@gmail.com>
Date: Thu Apr 3 22:18:29 2025 +0300
build: add project file
```
Просмотр истории изменений конкретного файла
```
taa41@alextwix MINGW64 ~/Desktop/lab2/alice/project (main)
$ git log -- project.cbp
commit 08119ab107dc03debee74f7d7cb4f170bd9ecfac
Author: Alice (TupikovAA) <taa4178@gmail.com>
Date: Thu Apr 3 22:18:29 2025 +0300
build: add project file
```
Просмотр изменений в предыдущем коммите
```
taa41@alextwix MINGW64 ~/Desktop/lab2/alice/project (main)
$ git show HEAD~1
commit 53966cbdb24ede979a2e3ea8e06272a95c928dd6
Author: Alice (TupikovAA) <taa4178@gmail.com>
Date: Thu Apr 3 22:25:33 2025 +0300
code: add diff
diff --git a/main.cpp b/main.cpp
index 293dda2..ed02797 100644
--- a/main.cpp
+++ b/main.cpp
@@ -7,5 +7,5 @@ int main()
cout << "Enter A and B: ";
int a, b;
cin >> a >> b;
- cout<<"a + b = "<<a+b;
+ cout<<"a + b = "<<a+b<<endl<<"a - b = "<<a-b;
}
```
Альтернативный способ просмотра предыдущего коммита
```
taa41@alextwix MINGW64 ~/Desktop/lab2/alice/project (main)
$ git show main~1
commit 53966cbdb24ede979a2e3ea8e06272a95c928dd6
Author: Alice (TupikovAA) <taa4178@gmail.com>
Date: Thu Apr 3 22:25:33 2025 +0300
code: add diff
diff --git a/main.cpp b/main.cpp
index 293dda2..ed02797 100644
--- a/main.cpp
+++ b/main.cpp
@@ -7,5 +7,5 @@ int main()
cout << "Enter A and B: ";
int a, b;
cin >> a >> b;
- cout<<"a + b = "<<a+b;
+ cout<<"a + b = "<<a+b<<endl<<"a - b = "<<a-b;
}
```
Просмотр конкретного коммита по хешу
```
taa41@alextwix MINGW64 ~/Desktop/lab2/alice/project (main)
$ git show 53966cbdb24ede979a2e3ea8e06272a95c928dd6
commit 53966cbdb24ede979a2e3ea8e06272a95c928dd6
Author: Alice (TupikovAA) <taa4178@gmail.com>
Date: Thu Apr 3 22:25:33 2025 +0300
code: add diff
diff --git a/main.cpp b/main.cpp
index 293dda2..ed02797 100644
--- a/main.cpp
+++ b/main.cpp
@@ -7,5 +7,5 @@ int main()
cout << "Enter A and B: ";
int a, b;
cin >> a >> b;
- cout<<"a + b = "<<a+b;
+ cout<<"a + b = "<<a+b<<endl<<"a - b = "<<a-b;
}
```
Сравнение изменений между двумя коммитами
```
taa41@alextwix MINGW64 ~/Desktop/lab2/alice/project (main)
$ git diff HEAD~3 HEAD~1
diff --git a/main.cpp b/main.cpp
index 842760d..ed02797 100644
--- a/main.cpp
+++ b/main.cpp
@@ -7,5 +7,5 @@ int main()
cout << "Enter A and B: ";
int a, b;
cin >> a >> b;
-
+ cout<<"a + b = "<<a+b<<endl<<"a - b = "<<a-b;
}
```
Добавление изменений в main.cpp и создание коммита
```
taa41@alextwix MINGW64 ~/Desktop/lab2/alice/project (main)
$ git add main.cpp
$ git commit -m 'code: add multiply'
[main ae6cf31] code: add multiply
1 file changed, 1 insertion(+), 1 deletion(-)
```
Отмена последнего коммита
```
taa41@alextwix MINGW64 ~/Desktop/lab2/alice/project (main)
$ git reset --hard HEAD~1
HEAD is now at 072f731 git: add .gitignore
```
Восстановление файла main.cpp из последнего коммита
```
taa41@alextwix MINGW64 ~/Desktop/lab2/alice/project (main)
$ git checkout HEAD -- main.cpp
```
Генерация SSH-ключей
```
$ ssh-keygen
Generating public/private ed25519 key pair...
Your identification has been saved in /c/Users/taa41/.ssh/id_ed25519
Your public key has been saved in /c/Users/taa41/.ssh/id_ed25519.pub
```
Запуск SSH-агента
```
$ eval $(ssh-agent -s)
Agent pid 1401
```
Добавление SSH-ключа
```
$ ssh-add
Identity added: /c/Users/taa41/.ssh/id_ed25519 (taa41@alextwix)
```
Добавление удаленного репозитория
```
$ git remote add origin git@uit.mpei.ru:TwixAlex/cs-lab02.git
```
Первоначальная отправка изменений в удаленный репозиторий
```
$ git push -u origin main
Enumerating objects: 18, done.
Counting objects: 100% (18/18), done.
Delta compression using up to 8 threads
Compressing objects: 100% (16/16), done.
Writing objects: 100% (18/18), 2.13 KiB | 182.00 KiB/s, done.
Total 18 (delta 2), reused 0 (delta 0)
To uit.mpei.ru:TwixAlex/cs-lab02.git
* [new branch] main -> main
```
Получение изменений с удаленного репозитория
```
$ git fetch
remote: Enumerating objects: 5, done.
remote: Counting objects: 100% (5/5), done.
remote: Compressing objects: 100% (3/3), done.
Unpacking objects: 100% (3/3), 357 bytes | 178.00 KiB/s, done.
```
Обновление локальной ветки с удаленного репозитория
```
$ git pull --ff-only
Updating 072f731..dd9b20f
Fast-forward
main.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
```
Создание коммита с изменениями и отправка на сервер
```
$ git add main.cpp
$ git commit -m 'code: добавлено деление'
[main dda83d9] code: добавлено деление
1 file changed, 1 insertion(+), 1 deletion(-)
$ git push
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), 399 bytes | 399.00 KiB/s, done.
Total 3 (delta 1), reused 0 (delta 0)
To uit.mpei.ru:TwixAlex/cs-lab02.git
dd9b20f..dda83d9 main -> main
```
Добавление новой функциональности и отправка на сервер
```
$ git add main.cpp
$ git commit -m 'code: add max value'
[main 4d8f736] code: add max value
1 file changed, 2 insertions(+), 1 deletion(-)
$ git push
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), 383 bytes | 383.00 KiB/s, done.
Total 3 (delta 1), reused 0 (delta 0)
To uit.mpei.ru:TwixAlex/cs-lab02.git
dda83d9..4d8f736 main -> main
```
Проверка статуса отправки изменений
```
$ git push
Everything up-to-date
```
Клонирование репозитория в директорию project
```
$ git clone git@uit.mpei.ru:TwixAlex/cs-lab02.git project
Cloning into 'project'...
remote: Enumerating objects: 18, done.
remote: Counting objects: 100% (18/18), done.
remote: Compressing objects: 100% (16/16), done.
remote: Total 18 (delta 2), reused 0 (delta 0)
Receiving objects: 100% (18/18), done.
Resolving deltas: 100% (2/2), done.
```
Переход в директорию проекта
```
$ cd project
```
Настройка имени пользователя для git в клонированном репозитории
```
$ git config user.name 'Bob (TupikovAA)'
```
Настройка email пользователя для git
```
$ git config user.email 'taa4178@gmail.com'
```
Добавление изменений и создание коммита
```
$ git add main.cpp
$ git commit -m 'code: add multiply'
[main dd9b20f] code: add multiply
1 file changed, 1 insertion(+), 1 deletion(-)
```
Отправка изменений на сервер
```
$ git push
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), 377 bytes | 377.00 KiB/s, done.
Total 3 (delta 1), reused 0 (delta 0)
To uit.mpei.ru:TwixAlex/cs-lab02.git
072f731..dd9b20f main -> main
```
Получение изменений с сервера
```
$ git fetch
remote: Enumerating objects: 5, done.
remote: Counting objects: 100% (5/5), done.
remote: Compressing objects: 100% (3/3), done.
Unpacking objects: 100% (3/3), 379 bytes | 54.00 KiB/s, done.
From uit.mpei.ru:TwixAlex/cs-lab02
dd9b20f..dda83d9 main -> origin/main
```
Обновление ветки main
```
$ git pull --ff-only
Updating dd9b20f..dda83d9
Fast-forward
main.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
```
Добавление изменений и создание коммита
```
$ git add main.cpp
$ git commit -m 'code: добавлен вывод минимума'
[main cd08170] code: добавлен вывод минимума
1 file changed, 2 insertions(+), 1 deletion(-)
```
Получение изменений с сервера
```
$ git fetch
remote: Enumerating objects: 5, done.
remote: Counting objects: 100% (5/5), done.
remote: Compressing objects: 100% (3/3), done.
Unpacking objects: 100% (3/3), 363 bytes | 45.00 KiB/s, done.
From uit.mpei.ru:TwixAlex/cs-lab02
dda83d9..4d8f736 main -> origin/main
```
Добавление изменений и попытка коммита
```
$ git add .
$ git commit -m 'git: fetched'
On branch main
Your branch and 'origin/main' have diverged,
and have 1 and 1 different commits each, respectively.
```
Попытка выполнить rebase (возник конфликт)
```
$ git rebase origin/main
Auto-merging main.cpp
CONFLICT (content): Merge conflict in main.cpp
error: could not apply cd08170... code: добавлен вывод минимума
```
Продолжение rebase
```
$ git rebase --continue
```
Переключение на ветку double
```
$ git checkout double
M .gitignore
Switched to branch 'double'
```
Добавление изменений и создание коммита в ветке double
```
$ git add main.cpp
$ git commit -m 'code: switch to double'
[double a19d1a7] code: switch to double
1 file changed, 1 insertion(+), 1 deletion(-)
```
Возврат на ветку main
```
$ git checkout main
M .gitignore
Switched to branch 'main'
Your branch is up to date with 'origin/main'.
```
Обновление ветки main с сервера
```
$ git pull
Already up to date.
```
Слияние ветки double с main
```
$ git merge double
Updating 4d8f736..a19d1a7
Fast-forward
main.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
```
Отправка изменений на сервер
```
$ git push
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), 363 bytes | 363.00 KiB/s, done.
Total 3 (delta 1), reused 0 (delta 0)
To uit.mpei.ru:TwixAlex/cs-lab02.git
4d8f736..a19d1a7 main -> main
```
Просмотр истории коммитов в виде графа
```
$ git log --oneline --decorate --all --graph
* a19d1a7 (HEAD -> main, origin/main, origin/HEAD, double) code: switch to double
* 4d8f736 code: add max value
* dda83d9 code: добавлено деление
* dd9b20f code: add multiply
* 072f731 git: add .gitignore
* 53966cb code: add diff
* 2690843 code: add sum
* a4aeeb1 code: add input
* 08119ab build: add project file
* 88d573e code: заготовка программы
```
Загрузка…
Отмена
Сохранить