Данная лабораторная работа посвещена изучению систем контроля версий на примере Git.
$ open https://git-scm.com
- 1. Создать публичный репозиторий с названием lab03 и с лиценцией MIT
- 2. Ознакомиться со ссылками учебного материала
- 3. Выполнить инструкцию учебного материала
- 4. Составить отчет и отправить ссылку личным сообщением в Slack
$ export GITHUB_USERNAME=hackallcode
$ export GITHUB_EMAIL=login@mail.ru
$ alias edit=nano
$ mkdir lab03 && cd lab03 # Создаем папку
$ git init # Инициализация гита в папке
$ git config --global user.name ${GITHUB_USERNAME} # Настройка Git Config
$ git config --global user.email ${GITHUB_EMAIL} # UP
$ git config -e --global # Просмотр / правка Git Config
$ git remote add origin https://github.com/${GITHUB_USERNAME}/BMSTU-Projects-3rd-Semester # Привязка к папке репозитория
$ git pull origin master # Подтягиваем данные с гита
$ touch README.md # Создаем README
$ git status # Смотрим, какие файлы не добавлены и т.д.
$ git add README.md # Добавление файла в индексацию гита
$ git commit -m "Added README.md" # Описываем изменения
$ git push origin master # Заливаем на Git
Добавить на сервисе GitHub в репозитории lab03 файл .gitignore со следующем содержимом:
*build*/
*install*/
*.swp
$ git pull origin master # Получаем
$ git log # Смотрим изменения
$ mkdir sources
$ mkdir include
$ mkdir examples
$ cat > sources/print.cpp <<EOF # Создаем файлики
#include <print.hpp>
void print(const std::string& text, std::ostream& out) {
out << text;
}
void print(const std::string& text, std::ofstream& out) {
out << text;
}
EOF
$ cat > include/print.hpp <<EOF # Ещё один
#include <string>
#include <fstream>
#include <iostream>
void print(const std::string& text, std::ostream& out = std::cout);
void print(const std::string& text, std::ofstream& out);
EOF
$ cat > examples/example1.cpp <<EOF # И ещё
#include <print.hpp>
int main(int argc, char** argv) {
print("hello");
}
EOF
$ cat > examples/example2.cpp <<EOF # И ещё
#include <fstream>
#include <print.hpp>
int main(int argc, char** argv) {
std::ofstream file("log.txt");
print(std::string("hello"), file);
}
EOF
$ edit README.md
$ git status
$ git add .
$ git commit -m"added sources"
$ git push origin master
$ cd ~/workspace/labs/
$ export LAB_NUMBER=03
$ git clone https://github.com/tp-labs/lab${LAB_NUMBER} tasks/lab${LAB_NUMBER}
$ mkdir reports/lab${LAB_NUMBER}
$ cp tasks/lab${LAB_NUMBER}/README.md reports/lab${LAB_NUMBER}/REPORT.md
$ cd reports/lab${LAB_NUMBER}
$ edit REPORT.md
$ gistup -m "lab${LAB_NUMBER}"
Copyright (c) 2017 Братья Вершинины