Отчет по лабораторной работе № 2 «Система контроля версий Git» Выполнил: Карелина М.К. Группа: А-03-22 Проверил: Козлюк Д. А. 1. Создала на рабочем столе каталог lab02 и запустил в нем Git Bash, приглашение: Мария@Note-Mary MINGW64 ~/Desktop/lab02 $ ls 2. Просмотрела файлы в рабочем каталоге командой ls — пусто: Мария@Note-Mary MINGW64 ~/Desktop/lab02 $ ls Мария@Note-Mary MINGW64 ~/Desktop/lab02 $ 3. Создала каталоги Алисы и Боба, создала каталог 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/ 5. Настроила репозитарий так, чтобы коммиты были от имени Алисы Мария@Note-Mary MINGW64 ~/Desktop/lab02/alice/project (master) $ git config user.name 'Alice (KarelinaMK)' git config user.email 'KarelinaMK@mpei.ru' 6. Запускаем 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 9. Выполним коммит с файлом 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") 13. Заменим тело функции 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 3fa2b6a62dab4509956db6d66b1071240733f214 (HEAD -> master) Author: Alice (KarelinaMK) Date: Mon Mar 6 15:10:17 2023 +0300 git .gitignore | 2 ++ 1 file changed, 2 insertions(+) commit 3b4f9498587d54632d066d3d585eb1364cd464ef Author: Alice (KarelinaMK) 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 d2cf070b25b6b9568b8a746ba6f8451ed3d2e045 Author: Alice (KarelinaMK) Date: Mon Mar 6 14:27:02 2023 +0300 build project.cbp | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) commit f3f527116c9e0798e9f6169012fc9ef339e5427f Author: Alice (KarelinaMK) 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 3b4f9498587d54632d066d3d585eb1364cd464ef Author: Alice (KarelinaMK) 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: заготовка программы