This commit is contained in:
Andrei Astafev 2019-06-03 10:03:24 +03:00
parent e312541ae7
commit 02568f482b
2 changed files with 99 additions and 185 deletions

View File

@ -76,6 +76,14 @@ Hitchhikers Guide to the CMake]
== Начало проекта
Проект, в котором выполнены приведённые ниже действия, можно посмотреть
https://git.246060.ru/f1x1t/cmex[здесь] или сделать его копию командой:
[source,sh]
----
git clone --recursive https://git.246060.ru/f1x1t/cmex
----
В каталоге `cmex` нужно создать файл `CMakeLists.txt`:
[source,cmake]
@ -91,12 +99,17 @@ project(cmex VERSION 0.2.0 LANGUAGES C CXX)
Значение версии следует формировать согласно правилам
https://semver.org/lang/ru/[семантического версионирования].
В каталог `cmake/cmlib` установить подмодуль CMLib, содержащий функции
для CMake:
В каталоге `cmex` нужно инициализировать репозиторий и установить
подмодули, содержащие функции для CMake:
....
git submodule add ssh://git@gitlab-server/root/cmlib cmake/cmlib
....
[source,sh]
----
git init .
git submodule add https://git.246060.ru/f1x1t/cmlib cmake/cmlib
git submodule add https://git.246060.ru/f1x1t/cmake-find cmake/find
git submodule add https://git.246060.ru/f1x1t/cmake-generators cmake/generators
git submodule update --remote --init
----
и подключить в файле `CMakeLists.txt`:
@ -398,9 +411,9 @@ ExternalProject_Add(cmext
)
----
Вызовы этих функций нужно сделать до функций `add_subdirectories`,
чтобы в подключённых подкаталогах можно было использовать цель `cmext`
для определения зависимостей.
Вызовы этих функций нужно сделать до функций `add_subdirectories`, чтобы
в подключенных подкаталогах можно было использовать цель `cmext` для
определения зависимостей.
В файле `cmex/src/cmex/CMakeLists.txt` нужно подключить внешний проект
`cmext`:

View File

@ -51,7 +51,7 @@ sudo apt-get install git
Файлы в рабочем каталоге могут отслеживаться системой контроля версий
(tracked) или нет (untracked). Отслеживаемые файлы, которые на диаграмме
обозначены зелёным фоном, могут быть неизменёнными (unmodified),
изменёнными (modified) или подготовленными к фиксации (staged).
изменёнными (modified) или подготовленными к фиксации (indexed).
[.text-center]
@ -61,7 +61,7 @@ sudo apt-get install git
@startuml
participant untracked as "Неотслеживамые\n(untracked)"
box "Отслеживаемые"
participant staged as "Подготовленные к фиксации\n(staged)" #55FF55
participant staged as "Подготовленные к фиксации\n(indexed)" #55FF55
participant unmodified as "Неизменённые\n(unmodified)" #99FF99
participant modified as "Изменённые\n(modified)" #77FF77
end box
@ -176,225 +176,126 @@ git rm <path/to/submodule>
|`git commit` |`-a` |Зафиксировать все отслеживаемые файлы, которые были
изменены
|===
== Удаление
[width="100%",cols="20%,20%,60%",options="header",]
|===
|Команда |Ключи |Описание
|`git rm` |`<filename>` |Удалить файл из индекса и рабочего каталога
|`git rm` |`-f <filename>` |Force deletion of files from disk
|`git rm` |`-f <filename>` |Принудительное удаление файла
|`git rm` |`--cached <filename>` |Untrack file (without deleting)
|`git rm` |`--cached <filename>` |Удаление файла из проекта, но не из
рабочего каталога
|===
== Информация
[width="100%",cols="15%,25%,60%",options="header",]
[cols=",,",options="header",]
|===
|Команда |Ключи |Описание
|`git status` |`-s` |Вывод информации о рабочем каталоге в
краткой форме
|`git status` |`-s` |Вывод информации о рабочем каталоге в краткой форме
|`git log` |`--oneline` |Вывод журнала изменений в краткой форме
|`git ls-files` | |Вывод списка отслеживаемых и подготовленных файлов
|===
== $push branches (see tags for pushing tags)
== Удалённый репозиторий
[width="100%",cols="15%,25%,60%",options="header",]
[cols=",,",options="header",]
[width="100%",cols="20%,20%,60%",options="header",]
|===
|Команда |Ключи |Описание
|`git push` |`<remotename> <branchname>` |Push branch to remote
|`git push` |`<remotename> --all` |Push all branches to remote
|`git push` |`--d <remotename> <branchname>` |`--delete` remote branch
|`git remote` |`-v` |Список адресов удалённых репозиториев
|`git branch` |`-r` |Список веток в удалённых репозиториях
|`git remote` |`add <name> <url>` |Создать ссылку `<name>` на удалённый
репозиторий, находящийся по адресу `<url>`
|`git remote` |`rename <old> <new>` |Переименовать ссылку `<old>` на
`<new>`
|`git remote` |`rm <name>` |Удалить ссылку `<name>`
|===
== $remote
* Обращение к удалённому репозиторию осуществляется по ссылке,
создаваемой командой `git remote`
* Команда `git clone` автоматически создаёт ссылку `origin`
* Remote connections are like bookmarks named after remote repos
* `git clone` automatically creates a remote connection usually called
`origin`
== Отправка изменений
[width="100%",cols="15%,25%,60%",options="header",]
[width="100%",cols="36%,26%,38%",options="header",]
[width="100%",cols="20%,20%,60%",options="header",]
|===
|Команда |Ключи |Описание
|`git remote` |`-v` |List remote repository endpoints
|`git push` |`<remote> <branch>` |Отправить ветку `<branch>` в удалённый
репозиторий `<remote>`
|`git branch` |`-r` |List remote repository branches
|`git push` |`<remote> --all` |Отправить все ветки в удалённый
репозиторий `<remote>`
|`git remote` |`add <name> <url>` |Create namespaced connection to a
remote repository
|`git remote` |`rename <oldname> <newname>` |Rename connection
|`git remote` |`rm <name>` |Remove connection
|`git remote` |`add origin <url>` |Set remote origin
|`git push` |`--d <remote> <branch>` |Удалить ветку `<branch>` из
удалённого репозитория `<remote>`
|===
Reference: https://git-scm.com/docs/git-remote
== Получение изменений
*Remove remote origin:*
[source,shell]
----
# Remove `origin` settings from .git/config
git remote rm origin
# Remove `FETCH_HEAD` which still points to remote
git rm .git/FETCH_HEAD
----
== $fetch-pull
[width="100%",cols="15%,25%,60%",options="header",]
[width="100%",cols="20%,20%,60%",options="header",]
|===
|Команда |Ключи |Описание
|`git fetch` |`<remote>` |Fetch all branches from remote (without merge)
|`git fetch` |`<remote> <branch>` |Fetch specific branch
|`git merge` |`<remote>/<branch>` |Merge fetched remote
|`git pull` |`<remote>` |Fetch and merge in one command
|`git fetch` |`<remote>` |Получить изменения из всех веток репозитория
`<remote>`, но не выполнять слияние
|`git fetch` |`<remote> <branch>` |Получить изменения из ветки
`<branch>` репозитория `<remote>`, но не выполнять слияние
|`git merge` |`<remote>/<branch>` |Выполнить слияние с веткой `<branch>`
репозитория `<remote>`
|`git pull` |`<remote>` |Получение и слияние
|===
Reference: https://git-scm.com/docs/git-fetch,
https://git-scm.com/docs/git-pull
== $branch
== Ветки
[cols=",,",options="header",]
|===
|Команда |Ключи |Описание
|`git branch` | |List branches
|`git branch` |`-a` |Список локальных и удалённых веток
|`git branch` |`<branchname>` |Create new branch
|`git branch` | |Список локальных веток
|`git checkout` |`<sha-1>` |Switch to branch, or commit
|`git branch` |`<branch>` |Создать ветку `<branch>`
|`git branch` |`-m <branchname> <newname>` |Rename branch
|`git checkout` |`<sha-1>` |Перейти к фиксации с идентификатором
`<sha-1>`
|`git merge` |`<branchname>` |Merge changes from `<branchname>` to
current branch
|`git branch` |`-m <old> <new>` |Переименовать ветку `<old>` в `<new>`
|`git branch` |`-d <branchname>` |`--delete` branch
|`git merge` |`<branch>` |Слить изменения из ветки `<branch>` в текущую
ветку
|`git branch` |`-d <branch>` |Удалить ветку `<branch>`
|===
Reference: https://git-scm.com/docs/git-branch
== Сравнение
== $diff
[cols=",,",options="header",]
[width="100%",cols="20%,20%,60%",options="header",]
|===
|Команда |Ключи |Описание
|`git diff` | |Compare *`working directory`* and *`index`*
| |`-cached` |Compare *`index`* and *`latest commit`*
| |`HEAD` |Compare *`latest commit`* and *`working directory`*
| |`--stat` |Optional short format
| |`<sha-1> <sha-1>` |2 points in time to compare
| |`<dir> | <file>` |Compare whole directory or limit to file
|`git diff` | |Сравнить рабочий каталог и индекс
|`git diff` |`-cached` |Сравнить индекс и последнюю фиксацию
|`git diff` |`HEAD` |Сравнить последнюю фиксацию и рабочий каталог
|`git diff` |`--stat` |Краткий вывод результатов
|`git diff` |`<sha-1> <sha-1>` |Сравнить две точки с указанными
идентификаторами
|`git diff` |`<dir>` `<file>` |Сравнивать только указанный каталог
`<dir>` или файл `<file>`
|`git difftool` | |Отобразить результаты сравнения в программе,
определяемой переменной `diff.tool`
|===
Reference: https://git-scm.com/docs/git-diff
*Examples:*
[source,shell]
----
## compare changes made to README.md between working tree (default) and latest commit (HEAD)
$ git diff --stat HEAD ./path/README.md
## compare changes made to README.md between 2 specific points in time (e.g. 2 commits)
$ git diff --stat a649900 24bdd58 ./path/README.md
----
== $tag
[width="100%",cols="36%,26%,38%",options="header",]
|===
|Команда |Ключи |Описание
|`git tag` | |List tags
|`git tag` |`<v1.0.0>` |Create tag, from latest commit, lightweight
|`git tag` |`-a <v1.0.0> -m "<msg>"` |Create tag, with `--annotate`,
from latest commit
|`git tag` |`-a <v1.0.0> -m "<msg>" <SHA-1>` |Create tag, with
`--annotate`, from specific commit
|`git tag` |`-d <v1.1.0>` |`--delete` tag
|`git show` |`<v1.0.0>` |Show tag data and message
|`git checkout` |`<v1.0.0>` |Switch to specific point tag (not editable)
|`git push` |`<remote> <tag>` |Push specific tag to `<remote>`
(recommended)
|`git push` |`<remote> --tags` |Push all tags to `<remote>` (only if
necessary)
|===
Инициализация репозитория в каталоге `dir`:
[source,sh]
----
git init dir
----
Клонирование репозитория `repo`, принадлежащего пользователю `user`, с
сервера `gitlab.2` в каталог `dir`:
[source,sh]
----
git clone git@gitlab.2:user/repo.git dir
----
Просмотр состояния рабочего каталога и репозитория:
[source,sh]
----
git status
----
Краткая форма вывода состояния:
[source,sh]
----
git status -s
----
Добавление файла `README.md` под версионный контроль и подготовка к
фиксации:
[source,sh]
----
git add README.md
----
Удаление файла `README.md` из индекса репозитория:
[source,sh]
----
git rm --cached README.md
----
Зафиксировать файлы, подготовленные к фиксации:
[source,sh]
----
git commit
----
Зафиксировать все отслеживаемые файлы, которые были изменены:
[source,sh]
----
git commit -a
----
Отправить все ветки репозитория на сервер с меткой `origin`:
[source,sh]
----
git push origin
----