Skip to content

Instantly share code, notes, and snippets.

@hackallcode
Created September 22, 2017 20:42
Show Gist options
  • Save hackallcode/a7ce9b91e677bc69058723c10c2453f1 to your computer and use it in GitHub Desktop.
Save hackallcode/a7ce9b91e677bc69058723c10c2453f1 to your computer and use it in GitHub Desktop.
lab03

Laboratory work III

Данная лабораторная работа посвещена изучению систем контроля версий на примере Git.

$ open https://git-scm.com

Tasks

  • 1. Создать публичный репозиторий с названием lab03 и с лиценцией MIT
  • 2. Ознакомиться со ссылками учебного материала
  • 3. Выполнить инструкцию учебного материала
  • 4. Составить отчет и отправить ссылку личным сообщением в Slack

Tutorial

Задаем переменные окружения

$ 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

Редактируем README

$ edit README.md

Заливаем изменения по старой схеме

$ git status
$ git add .
$ git commit -m"added sources"
$ git push origin master

Report

Создаем и заливаем отчёт

$ 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}"

Links

Copyright (c) 2017 Братья Вершинины
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment