|
2 лет назад | |
---|---|---|
.gitignore | 2 лет назад | |
README.md | 2 лет назад | |
main.cpp | 2 лет назад | |
project.cbp | 2 лет назад |
README.md
Отчет по лабораторной работе № 2 «Система контроля версий Git»
Выполнил: Карелина М.К. Группа: А-03-22 Проверил: Козлюк Д. А.
- Создала на рабочем столе каталог lab02 и запустил в нем Git Bash, приглашение: Мария@Note-Mary MINGW64 ~/Desktop/lab02 $ ls
- Просмотрела файлы в рабочем каталоге командой ls — пусто: Мария@Note-Mary MINGW64 ~/Desktop/lab02 $ ls Мария@Note-Mary MINGW64 ~/Desktop/lab02 $
- Создала каталоги Алисы и Боба, создала каталог project, изучила команду cd в процессе: Мария@Note-Mary MINGW64 ~/Desktop/lab02 $ mkdir alice
Мария@Note-Mary MINGW64 ~/Desktop/lab02 $ mkdir bob
Мария@Note-Mary MINGW64 ~/Desktop/lab02 $ ls alice/ bob/
Мария@Note-Mary MINGW64 ~/Desktop/lab02 $ cd alice
Мария@Note-Mary MINGW64 ~/Desktop/lab02/alice $ mkdir project
Мария@Note-Mary MINGW64 ~/Desktop/lab02/alice $ cd project 4. Инициализировала репозиторарий в текущем каталоге Мария@Note-Mary MINGW64 ~/Desktop/lab02/alice/project $ git init Initialized empty Git repository in C:/Users/Мария/Desktop/lab02/alice/project/. git/
-
Настроила репозитарий так, чтобы коммиты были от имени Алисы Мария@Note-Mary MINGW64 ~/Desktop/lab02/alice/project (master) $ git config user.name 'Alice (KarelinaMK)' git config user.email 'KarelinaMK@mpei.ru'
-
Запускаем CodeBlocks и создаем проект в репозитарии Алисы, собираем его. Просмотрим состояние рабочей копии Мария@Note-Mary MINGW64 ~/Desktop/lab02/alice/project (master) $ git status Запрос статуса On branch master // на ветке мастера (основной пользователь запрашивает)
No commits yet // никаких сохраненных в гите изменений
Untracked files: // неотслеживаемые файлы (use "git add ..." to include in what will be committed) main.cpp project.cbp project.layout
nothing added to commit but untracked files present (use "git add" to track) 7. добавила main.cpp в отслежиавемые файлы Мария@Note-Mary MINGW64 ~/Desktop/lab02/alice/project (master) $ git add main.cpp 8. Отследила результат Мария@Note-Mary MINGW64 ~/Desktop/lab02/alice/project (master) $ git status On branch master
No commits yet
Changes to be committed: //изменения, которые должны быть закоммичены (use "git rm --cached ..." to unstage) new file: main.cpp
Untracked files: (use "git add ..." to include in what will be committed) project.cbp project.layout
- Выполним коммит с файлом main.cpp и коротким сообщением
Мария@Note-Mary MINGW64 ~/Desktop/lab02/alice/project (master)
$ git commit -m 'code: заготовка программы'
[master (root-commit) f3f5271
] code: заготовка программы
1 file changed, 9 insertions(+)
create mode 100644 main.cpp
10. добавила project в индекс
Мария@Note-Mary MINGW64 ~/Desktop/lab02/alice/project (master)
$ git add project.cbp
warning: in the working copy of 'project.cbp', LF will be replaced by CRLF the n
ext time Git touches it
11. Выполним коммит с файлом main.cpp и темой build:
Мария@Note-Mary MINGW64 ~/Desktop/lab02/alice/project (master)
$ git commit -m 'build'
[master d2cf070
] build
1 file changed, 40 insertions(+)
create mode 100644 project.cbp
12. Посмотрим состояние рабочей копии
Мария@Note-Mary MINGW64 ~/Desktop/lab02/alice/project (master) $ git status On branch master Changes not staged for commit: (use "git add ..." to update what will be committed) (use "git restore ..." to discard changes in working directory) modified: main.cpp
Untracked files: (use "git add ..." to include in what will be committed) project.layout
no changes added to commit (use "git add" and/or "git commit -a")
- Заменим тело функции main() на ввод двух чисел:
cout << "Enter A and B: "; int a, b; cin >> a >> b;
Мария@Note-Mary MINGW64 ~/Desktop/lab02/alice/project (master) $ git status On branch master Changes not staged for commit: (use "git add ..." to update what will be committed) (use "git restore ..." to discard changes in working directory) modified: main.cpp
Untracked files: (use "git add ..." to include in what will be committed) project.layout bin/ obj/
Мария@Note-Mary MINGW64 ~/Desktop/lab02/alice/project (master) $ git add main.cpp
Мария@Note-Mary MINGW64 ~/Desktop/lab02/alice/project (master)
$ git commit -m "added search for the sum of numbers"
[master 3c32ed0
] added search for the sum of numbers
1 file changed, 4 insertions(+), 2 deletions(-)
Мария@Note-Mary MINGW64 ~/Desktop/lab02/alice/project (master)
$ git commit -a -m "added search for the sum and dif"
[master 3b4f949
] added search for the sum and dif
1 file changed, 2 insertions(+)
15. Укажем Git игнорировать присутствие каталога bin. Для этого создадим в CodeBlocks новый файл (File → New... → Empty) и запишем в него строку:
/bin добавим новый файл в индекс Мария@Note-Mary MINGW64 ~/Desktop/lab02/alice/project (master) $ git add .gitignore
Мария@Note-Mary MINGW64 ~/Desktop/lab02/alice/project (master)
$ git commit -m "git"
[master 3fa2b6a
] git
1 file changed, 2 insertions(+)
create mode 100644 .gitignore
Мария@Note-Mary MINGW64 ~/Desktop/lab02/alice/project (master) $ git status On branch master Untracked files: (use "git add ..." to include in what will be committed) project.depend project.layout
nothing added to commit but untracked files present (use "git add" to track)
16. Просмотр истории
Мария@Note-Mary MINGW64 ~/Desktop/lab02/alice/project (master)
$ git log --stat
commit 3fa2b6a62d
(HEAD -> master)
Author: Alice (KarelinaMK) KarelinaMK@mpei.ru
Date: Mon Mar 6 15:10:17 2023 +0300
git
.gitignore | 2 ++ 1 file changed, 2 insertions(+)
commit 3b4f949858
Author: Alice (KarelinaMK) KarelinaMK@mpei.ru
Date: Mon Mar 6 14:49:50 2023 +0300
added search for the sum of numbers
main.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
commit d2cf070b25
Author: Alice (KarelinaMK) KarelinaMK@mpei.ru
Date: Mon Mar 6 14:27:02 2023 +0300
build
project.cbp | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+)
commit f3f527116c
Author: Alice (KarelinaMK) KarelinaMK@mpei.ru
Date: Mon Mar 6 14:18:52 2023 +0300
code: заготовка программы
main.cpp | 9 +++++++++
1 file changed, 9 insertions(+)
17. просмотр коммитов
Мария@Note-Mary MINGW64 ~/Desktop/lab02/alice/project (master)
$ git show HEAD~1
commit 3b4f949858
Author: Alice (KarelinaMK) KarelinaMK@mpei.ru
Date: Mon Mar 6 14:49:50 2023 +0300
added search for the sum and dif
diff --git a/main.cpp b/main.cpp index 04c77d9..6f78dbd 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'
-
<< "A - B = " << a - b << '\n';
} 18. Просмотр изменений Мария@Note-Mary MINGW64 ~/Desktop/lab02/alice/project (master) $ git diff diff --git a/main.cpp b/main.cpp // разница между алисой и бобом index 6f78dbd..cc11ab1 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';
}
Просмотрим историю всех веток Мария@Note-Mary MINGW64 ~/Desktop/lab02/alice/project (master) $ git log --oneline --decorate --all
6b0ae13
(HEAD, master) min bob
eeb2598
(origin/master, origin/HEAD) max al
da439d7
del al
261c99c
mult bob
992780d
first commit
3fa2b6a
git
3b4f949
added search for the sum and dif
3c32ed0
added search for the sum of numbers
d2cf070
build
f3f5271
code: заготовка программы
20. Синхронизируйте ветку main «на машине Алисы» с сервером. Просмотрите историю всех веток и занесите результат в отчет.
Мария@Note-Mary MINGW64 ~/Desktop/lab02/alice/project (main|MERGING)
$ git log --oneline --decorate --all
1b91802
(double) double
6b0ae13
(origin/main, origin/HEAD) min bob
eeb2598
(HEAD -> main) max al
da439d7
del al
261c99c
mult bob
992780d
first commit
3fa2b6a
git
3b4f949
added search for the sum and dif
3c32ed0
added search for the sum of numbers
d2cf070
build
f3f5271
code: заготовка программы
Мария@Note-Mary MINGW64 ~/Desktop/lab02/alice/project (main) $ git pull Enter passphrase for key '/c/Users/Мария/.ssh/id_rsa': Updating 6b0ae13..82762b6 Fast-forward README.md | 275 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ main.cpp | 19 +++-- 2 files changed, 286 insertions(+), 8 deletions(-)
Мария@Note-Mary MINGW64 ~/Desktop/lab02/alice/project (main) $ git log --graph --all --decorate --oneline
82762b6
(HEAD -> main, origin/main, origin/HEAD) recorddfff074
record998c172
.6b0ae13
min bobda439d7
del al | *1b91802
(double) double | *eeb2598
max al |/261c99c
mult bob992780d
first commit3fa2b6a
git3b4f949
added search for the sum and dif3c32ed0
added search for the sum of numbersd2cf070
buildf3f5271
code: заготовка программы
Мария@Note-Mary MINGW64 ~/Desktop/lab02/alice/project (main) $ git checkout double Switched to branch 'double'
Мария@Note-Mary MINGW64 ~/Desktop/lab02/alice/project (double) $ git checkout - Switched to branch 'main' Your branch is up to date with 'origin/main'. Соединение с веткой double Мария@Note-Mary MINGW64 ~/Desktop/lab02/alice/project (main) $ git merge double Auto-merging main.cpp CONFLICT (content): Merge conflict in main.cpp Automatic merge failed; fix conflicts and then commit the result.
Мария@Note-Mary MINGW64 ~/Desktop/lab02/alice/project (main|MERGING) $ git add main.cpp
Мария@Note-Mary MINGW64 ~/Desktop/lab02/alice/project (main|MERGING)
$ git commit -m "done"
[main 36ea1da
] done
Мария@Note-Mary MINGW64 ~/Desktop/lab02/alice/project (main) $ git merge double Already up to date.
Мария@Note-Mary MINGW64 ~/Desktop/lab02/alice/project (main) $ git pull Enter passphrase for key '/c/Users/Мария/.ssh/id_rsa': Already up to date.
Мария@Note-Mary MINGW64 ~/Desktop/lab02/alice/project (main) $ git push Enter passphrase for key '/c/Users/Мария/.ssh/id_rsa': Enumerating objects: 13, done. Counting objects: 100% (13/13), done. Delta compression using up to 8 threads Compressing objects: 100% (9/9), done. Writing objects: 100% (9/9), 874 bytes | 437.00 KiB/s, done. Total 9 (delta 6), reused 0 (delta 0), pack-reused 0 remote: . Processing 1 references remote: Processed 1 references in total To uit.mpei.ru:KarelinaMK/cs-lab02.git 82762b6..36ea1da main -> main
Мария@Note-Mary MINGW64 ~/Desktop/lab02/alice/project (main) $ git log --graph --all --decorate --oneline
36ea1da
(HEAD -> main, origin/main, origin/HEAD) done |
| *1b91802
(double) double | *eeb2598
max al- |
82762b6
record - |
dfff074
record - |
998c172
. - |
6b0ae13
min bob - |
da439d7
del al |/ 261c99c
mult bob992780d
first commit3fa2b6a
git3b4f949
added search for the sum and dif3c32ed0
added search for the sum of numbersd2cf070
buildf3f5271
code: заготовка программы
Мария@Note-Mary MINGW64 ~/Desktop/lab02/alice/project (main) $