Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

436 строки
27 KiB
Plaintext

создание каталога
Kostello@Kostello-PC MINGW64 ~/Desktop/lubs/lub02
$ mkdir bob
Kostello@Kostello-PC MINGW64 ~/Desktop/lubs/lub02
$ mkdir alice
перемешение
Kostello@Kostello-PC MINGW64 ~/Desktop/lubs/lub02
$ cd alice
Kostello@Kostello-PC MINGW64 ~/Desktop/lubs/lub02/alice
$ cd ..
Kostello@Kostello-PC MINGW64 ~/Desktop/lubs/lub02
инициолизация
Kostello@Kostello-PC MINGW64 ~/Desktop/lubs/lub02/alice/project
$ git init
hint: Using 'master' as the name for the initial branch. This default branch name
hint: is subject to change. To configure the initial branch name to use in all
hint: of your new repositories, which will suppress this warning, call:
hint:
hint: git config --global init.defaultBranch <name>
hint:
hint: Names commonly chosen instead of 'master' are 'main', 'trunk' and
hint: 'development'. The just-created branch can be renamed via this command:
hint:
hint: git branch -m <name>
Initialized empty Git repository in C:/Users/Kostello/Desktop/lubs/lub02/alice/project/.git/
Kostello@Kostello-PC MINGW64 ~/Desktop/lubs/lub02/alice/project (master)
Настройте свое имя пользователя и почту МЭИ
Kostello@Kostello-PC MINGW64 ~/Desktop/lubs/lub02/alice/project (master)
$ git config user.name 'Alice (KanishchevYA)'
Kostello@Kostello-PC MINGW64 ~/Desktop/lubs/lub02/alice/project (master)
$ git config user.email 'KanishchevYA@mpei.ru'~
проверка файлов
Kostello@Kostello-PC MINGW64 ~/Desktop/lubs/lub02/alice/project (master)
$ git status
On branch master
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)
Добавим файл main.cpp в индекс
Kostello@Kostello-PC MINGW64 ~/Desktop/lubs/lub02/alice/project (master)
$ git add main.cpp
повторная проверка статуса
Kostello@Kostello-PC MINGW64 ~/Desktop/lubs/lub02/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)
project.cbp
первый комит
Kostello@Kostello-PC MINGW64 ~/Desktop/lubs/lub02/alice/project (master)
$ git commit -m 'code: заготовка программы'
[master (root-commit) 7a8d6ee] code: заготовка программы
1 file changed, 9 insertions(+)
create mode 100644 main.cpp
переименование
Kostello@Kostello-PC MINGW64 ~/Desktop/lubs/lub02/alice/project (master)
$ git branch -m main
Kostello@Kostello-PC MINGW64 ~/Desktop/lubs/lub02/alice/project (main)
котит 2 (1способ)
Kostello@Kostello-PC MINGW64 ~/Desktop/lubs/lub02/alice/project (master)
$ git branch -m main
Kostello@Kostello-PC MINGW64 ~/Desktop/lubs/lub02/alice/project (main)
$ git add main.cpp
git commit -m "..."
[main 21941d1] ...
1 file changed, 4 insertions(+), 1 deletion(-)
комит 3 (2 способ)
Kostello@Kostello-PC MINGW64 ~/Desktop/lubs/lub02/alice/project (main)
$ git add -u
git commit -m "..."
[main 927f23f] ...
1 file changed, 1 insertion(+)
комит 4 (3 способ)
Kostello@Kostello-PC MINGW64 ~/Desktop/lubs/lub02/alice/project (main)
$ git commit -a -m "3s"
[main 4091dbe] 3s
1 file changed, 3 insertions(+), 1 deletion(-)
игнорирование
проверка
Kostello@Kostello-PC MINGW64 ~/Desktop/lubs/lub02/alice/project (main)
$ git status
On branch main
Untracked files:
(use "git add <file>..." to include in what will be committed)
.gitignore
obj/
project.cbp
nothing added to commit but untracked files present (use "git add" to track)
инециолизация файлов .gitignore и project.cbp
Kostello@Kostello-PC MINGW64 ~/Desktop/lubs/lub02/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
Kostello@Kostello-PC MINGW64 ~/Desktop/lubs/lub02/alice/project (main)
$ git add .gitignore
Kostello@Kostello-PC MINGW64 ~/Desktop/lubs/lub02/alice/project (main)
$ git commit -m "инециолизация файлов .gitignore и project.cbp"
[main 8bbd581] инециолизация файлов .gitignore и project.cbp
2 files changed, 43 insertions(+)
create mode 100644 .gitignore
create mode 100644 project.cbp
Kostello@Kostello-PC MINGW64 ~/Desktop/lubs/lub02/alice/project (main)
$ git status
On branch main
nothing to commit, working tree clean
Просмотр истории
Kostello@Kostello-PC MINGW64 ~/Desktop/lubs/lub02/alice/project (main)
$ git log
commit 8bbd5816ae1e60b78fdb56f016264cc581241db3 (HEAD -> main)
Author: Alice (KanishchevYA) <KanishchevYA@mpei.ru~>
Date: Mon Jun 5 01:03:50 2023 +0300
инециолизация файлов .gitignore и project.cbp
commit 8bbd5816ae1e60b78fdb56f016264cc581241db3 (HEAD -> main)
Author: Alice (KanishchevYA) <KanishchevYA@mpei.ru~>
Date: Mon Jun 5 01:03:50 2023 +0300
инециолизация файлов .gitignore и project.cbp
commit 4091dbe4cc81103ef01042a56753c2416be4febf
Author: Alice (KanishchevYA) <KanishchevYA@mpei.ru~>
Date: Mon Jun 5 00:31:09 2023 +0300
3s
commit 927f23f30d58fbaed8a79eea5c0532fbfcc7fa78
Author: Alice (KanishchevYA) <KanishchevYA@mpei.ru~>
Date: Mon Jun 5 00:29:19 2023 +0300
...
commit 21941d1f5d9029b4ee18f352ecc521c0d7037aca
Author: Alice (KanishchevYA) <KanishchevYA@mpei.ru~>
Date: Mon Jun 5 00:26:59 2023 +0300
...
commit 7a8d6ee9f5152cd79de72c2af4bb88229e845619
Author: Alice (KanishchevYA) <KanishchevYA@mpei.ru~>
Date: Mon Jun 5 00:23:33 2023 +0300
Kostello@Kostello-PC MINGW64 ~/Desktop/lubs/lub02/alice/project (main)
$ git log --stat
commit 8bbd5816ae1e60b78fdb56f016264cc581241db3 (HEAD -> main)
Author: Alice (KanishchevYA) <KanishchevYA@mpei.ru~>
Date: Mon Jun 5 01:03:50 2023 +0300
инециолизация файлов .gitignore и project.cbp
.gitignore | 3 +++
project.cbp | 40 ++++++++++++++++++++++++++++++++++++++++
2 files changed, 43 insertions(+)
commit 4091dbe4cc81103ef01042a56753c2416be4febf
Author: Alice (KanishchevYA) <KanishchevYA@mpei.ru~>
Date: Mon Jun 5 00:31:09 2023 +0300
3s
main.cpp | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
commit 927f23f30d58fbaed8a79eea5c0532fbfcc7fa78
Author: Alice (KanishchevYA) <KanishchevYA@mpei.ru~>
Date: Mon Jun 5 00:29:19 2023 +0300
:...skipping...
commit 8bbd5816ae1e60b78fdb56f016264cc581241db3 (HEAD -> main)
Author: Alice (KanishchevYA) <KanishchevYA@mpei.ru~>
Date: Mon Jun 5 01:03:50 2023 +0300
инециолизация файлов .gitignore и project.cbp
.gitignore | 3 +++
project.cbp | 40 ++++++++++++++++++++++++++++++++++++++++
2 files changed, 43 insertions(+)
commit 4091dbe4cc81103ef01042a56753c2416be4febf
Author: Alice (KanishchevYA) <KanishchevYA@mpei.ru~>
Date: Mon Jun 5 00:31:09 2023 +0300
3s
main.cpp | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
commit 927f23f30d58fbaed8a79eea5c0532fbfcc7fa78
Author: Alice (KanishchevYA) <KanishchevYA@mpei.ru~>
Date: Mon Jun 5 00:29:19 2023 +0300
...
:
коммиты затрагивающие project.cbp
Kostello@Kostello-PC MINGW64 ~/Desktop/lubs/lub02/alice/project (main)
$ git log -- project.cbp
commit 8bbd5816ae1e60b78fdb56f016264cc581241db3 (HEAD -> main)
Author: Alice (KanishchevYA) <KanishchevYA@mpei.ru~>
Date: Mon Jun 5 01:03:50 2023 +0300
инециолизация файлов .gitignore и project.cbp
коммиты по теме code
Kostello@Kostello-PC MINGW64 ~/Desktop/lubs/lub02/alice/project (main)
$ git log --grep "code:"
commit 7a8d6ee9f5152cd79de72c2af4bb88229e845619
Author: Alice (KanishchevYA) <KanishchevYA@mpei.ru~>
Date: Mon Jun 5 00:23:33 2023 +0300
code: заготовка программы
Просмотр коммитов
предпоследний комит
1 способ
Kostello@Kostello-PC MINGW64 ~/Desktop/lubs/lub02/alice/project (main)
$ git show HEAD~1
commit 4091dbe4cc81103ef01042a56753c2416be4febf
Author: Alice (KanishchevYA) <KanishchevYA@mpei.ru~>
Date: Mon Jun 5 00:31:09 2023 +0300
3s
diff --git a/main.cpp b/main.cpp
index 1d5d9c2..f40bc6c 100644
--- a/main.cpp
+++ b/main.cpp
@@ -7,7 +7,9 @@ int main()
cout << "Enter A and B: ";
int a, b;
cin >> a >> b;
-cout << "A + B = " << a+b;
+cout << "A + B = " << a + b << '\n'
+ << "A - B = " << a - b << '\n';
+
return 0;
}
2 способ
Kostello@Kostello-PC MINGW64 ~/Desktop/lubs/lub02/alice/project (main)
$ git show 4091db
commit 4091dbe4cc81103ef01042a56753c2416be4febf
Author: Alice (KanishchevYA) <KanishchevYA@mpei.ru~>
Date: Mon Jun 5 00:31:09 2023 +0300
3s
diff --git a/main.cpp b/main.cpp
index 1d5d9c2..f40bc6c 100644
--- a/main.cpp
+++ b/main.cpp
@@ -7,7 +7,9 @@ int main()
cout << "Enter A and B: ";
int a, b;
cin >> a >> b;
-cout << "A + B = " << a+b;
+cout << "A + B = " << a + b << '\n'
+ << "A - B = " << a - b << '\n';
+
return 0;
}
3 способ
Kostello@Kostello-PC MINGW64 ~/Desktop/lubs/lub02/alice/project (main)
$ git show main
commit 8bbd5816ae1e60b78fdb56f016264cc581241db3 (HEAD -> main)
Author: Alice (KanishchevYA) <KanishchevYA@mpei.ru~>
Date: Mon Jun 5 01:03:50 2023 +0300
инециолизация файлов .gitignore и project.cbp
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..9d83ebf
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,3 @@
+/bin
+/obj
+*.layout
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>
:
Просмотр изменений
Kostello@Kostello-PC MINGW64 ~/Desktop/lubs/lub02/alice/project (main)
$ git diff
diff --git a/main.cpp b/main.cpp
index f40bc6c..ae041c8 100644
--- a/main.cpp
+++ b/main.cpp
@@ -8,7 +8,8 @@ cout << "Enter A and B: ";
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;
изменения между самым первым коммитом и коммитом, добавляющим вывод разности.
Kostello@Kostello-PC MINGW64 ~/Desktop/lubs/lub02/alice/project (main)
$ git diff HEAD~4 HEAD~1
diff --git a/main.cpp b/main.cpp
index b4392ec..f40bc6c 100644
--- a/main.cpp
+++ b/main.cpp
@@ -4,6 +4,12 @@ using namespace std;
int main()
{
- cout << "Hello world!" << endl;
+cout << "Enter A and B: ";
+int a, b;
+cin >> a >> b;
+cout << "A + B = " << a + b << '\n'
+ << "A - B = " << a - b << '\n';
+
+
return 0;
}
Откат изменений
комит произведения
Kostello@Kostello-PC MINGW64 ~/Desktop/lubs/lub02/alice/project (main)
$ git add main.cpp
Kostello@Kostello-PC MINGW64 ~/Desktop/lubs/lub02/alice/project (main)
$ git commit -m "code: вывод произведения"
[main 3ffab6b] code: вывод произведения
1 file changed, 2 insertions(+), 1 deletion(-)
откат к предидушему комиту
Kostello@Kostello-PC MINGW64 ~/Desktop/lubs/lub02/alice/project (main)
$ git reset --hard HEAD~1
HEAD is now at 8bbd581 инециолизация файлов .gitignore и project.cbp
удаление незакомиченых изменений
Kostello@Kostello-PC MINGW64 ~/Desktop/lubs/lub02/alice/project (main)
$ git checkout HEAD -- main.cpp
Обмен кодом через удаленное хранилище
Настройка SSH
создание ключа
Kostello@Kostello-PC MINGW64 ~/Desktop/lubs/lub02/alice/project (main)
$ ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/c/Users/Kostello/.ssh/id_rsa):
Created directory '/c/Users/Kostello/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /c/Users/Kostello/.ssh/id_rsa
Your public key has been saved in /c/Users/Kostello/.ssh/id_rsa.pub
The key fingerprint is:
SHA256:aFmc/ym1v7TPZ6YlN0DuI5ObRaCS5lJBo92D0wfm3kQ Kostello@Kostello-PC
The key's randomart image is:
+---[RSA 3072]----+
| o o E |
| +.B.o |
| . =+= + . |
| +=.* + |
| +=So...+ |
| .+ . o+o. |
| . . .+++o.o|
| . .*o.*=|
| o =*+|
+----[SHA256]-----+
Запустить агент:
Kostello@Kostello-PC MINGW64 ~/Desktop/lubs/lub02/alice/project (main)
$ eval $(ssh-agent -s)
Agent pid 628
Загрузить ключ (потребуется ввести пароль):
Kostello@Kostello-PC MINGW64 ~/Desktop/lubs/lub02/alice/project (main)
$ ssh-add
Identity added: /c/Users/Kostello/.ssh/id_rsa (Kostello@Kostello-PC)
Отобразить открытый ключ
Kostello@Kostello-PC MINGW64 ~/Desktop/lubs/lub02/alice/project (main)
$ cat ~/.ssh/id_rsa.pub
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQC9bJNuVBFg3whOlVbnI21vkrVnDLiiIco6FN/pZW7qvTjcu1COhtrVJI97/lQ2utY0fp+fxJ8VnGeNKVFQZf3n8pA9pOwlSedca2hmNvCXHCv6xc8JaEMN2d2S7eNUWLdXLSsQ9kU1eJBNQ7OIfcqKv2jlHH42Z9QqVgDUdnhANVmFhsht51uF+7yxkGOvOXJJwCsLKI7My20aiDja7lKnoOqK0x90fnVOkmvTOw/4vo93OZkFf5U/IrpUXLardf2iCnKN0ADMrJdV8/XY/giNRo2arYvWlV27FC/flC4l6HQibWp+Moh+CPc8JC+R3mnpK/6NZOHNplBLoVK17xx0TwLjII8IqH9zADbO/26tmqkfnDQHbQ2zfpXhrwS9DI9ruMKIh6Rz9GtqEwlvbP7hUwmMvmNAqN7kS7IsYr4N26fSx95IzEuKVim6rshOs1m4jaNURqdYB/7AZAYZOM7f2rk2qUNzOsGDeT1rMhluumYCbb7qmHy3u5OYajXXJFs= Kostello@Kostello-PC
Отправка проекта на сервер
Kostello@Kostello-PC MINGW64 ~/Desktop/lubs/lub02/alice/project (main)
$ git remote add origin git@uit.mpei.ru:KanishchevYA/cs-lab02.2.git
git push -u origin main
ssh: connect to host uit.mpei.ru port 22: Connection timed out
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.