

Содержание
-
История и внутреннее устройство
-
Локальный репозиторий
-
Практика
-
Удаленный репозиторий
-
Продвинутые команды
Система контроля версий (СКВ)
- Записывает изменения файлов
- Возвращает к старой версии
- Показывает изменения и кто их сделал

Централизованные СКВ

Децентрализованные СКВ




S
V
N
G
I
T
Про git
- Создатель Линус Торвальдс
-
He described the tool as "the stupid content tracker"
-
- Спроектирован для версионирования ядра линукс
- Первая версия через 3 дня
- Основные цели:
- Скорость
- Поддержка параллельной разработки
- Полная децентрализация






Содержание
-
История и внутреннее устройство
-
Локальный репозиторий
-
Практика
-
Удаленный репозиторий
-
Продвинутые команды
Создание ветки

Создание ветки

$ git branch testing
Создание ветки
$ git checkout testing

Создание ветки

$ git commit -m "A"
$ git checkout master
$ git commit -m "B"
Слияние веток

Слияние веток

$ git checkout master
$ git merge hotfix
Updating f42c576..3a0874c
Fast-forward
index.html | 2 ++
1 file changed, 2 insertions(+)
Three-way merge

Three-way merge

$ git checkout master
Switched to branch 'master'
$ git merge iss53
Merge made by the 'recursive' strategy.
index.html | 1 +
1 file changed, 1 insertion(+)
Three-way merge

Содержание
-
История и внутреннее устройство
-
Локальный репозиторий
-
Практика
-
Удаленный репозиторий
-
Продвинутые команды
Начало работы
- установка git
- Утилита git config
- /etc/gitconfig (--system)
- ~/.gitconfig (--global)
- .git/config
- помощь
- git help add
- man git-add
- git add --help
Начало работы
$ git init
Initialized empty Git repository in /home/eugene/temp/test_git/.git/
$ vim big_integer.h # edit big_integer.h
$ git add big_integer.h
$ git commit -m "add constructors from int and from string"
[master (root-commit) 34c2334] add constructors from int and from string
1 file changed, 8 insertions(+)
create mode 100644 big_integer.h
git diff
$ git diff
$ git diff
diff --git a/big_integer.h b/big_integer.h
index 00968ba..3e719b0 100644
--- a/big_integer.h
+++ b/big_integer.h
@@ -5,4 +5,6 @@
class big_integer {
big_integer(int x);
big_integer(const std::string &s);
+
+ std::string to_string() const;
};
$ git add big_integer.h
$ git diff
$ echo -n "\nbig_integer operator+;\n" >> big_integer.h
$ git diff
diff --git a/big_integer.h b/big_integer.h
index 3e719b0..b864002 100644
--- a/big_integer.h
+++ b/big_integer.h
@@ -8,3 +8,4 @@ class big_integer {
std::string to_string() const;
};
+big_integer operator+;
$ git status
On branch master
Changes to be committed:
(use "git reset HEAD <file>..." to unstage)
modified: big_integer.h
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)
modified: big_integer.h
git log
$ git log
commit ca82a6dff817ec66f44342007202690a93763949
Author: Scott Chacon <schacon@gee-mail.com>
Date: Mon Mar 17 21:52:11 2008 -0700
changed the version number
commit 085bb3bcb608e1e8451d4b2432f8ecbe6306e7e7
Author: Scott Chacon <schacon@gee-mail.com>
Date: Sat Mar 15 16:40:33 2008 -0700
removed unnecessary test
$ git log -2
$ git log -p
$ git log --stat
$ git log --graph
* 2d3acf9 ignore errors from SIGCHLD on trap
* 5e3ee11 Merge branch 'master' of git://github.com/dustin/grit
|\
| * 420eac9 Added a method for getting the current branch.
* | 30e367c timeout code and tests
* | 5a09431 add timeout protection to grit
* | e1193f8 support for heads with slashes in them
|/
* d6016bc require time for xmlschema
$ git log --pretty
git branch
$ git branch
iss53
* master
testing
$ git branch -v
iss53 93b412c fix javascript issue
* master 7a98805 Merge branch 'iss53'
testing 782fd34 add scott to the author list in the readmes
$ git branch testing
$ git branch -d testing
error: The branch 'testing' is not fully merged.
If you are sure you want to delete it, run 'git branch -D testing'.
.gitignore
$ cat .gitignore
# no .a files
*.a
# but do track lib.a, even though you're ignoring .a files above
!lib.a
# only ignore the root TODO file, not subdir/TODO
/TODO
# ignore all files in the build/ directory
build/
# ignore doc/notes.txt, but not doc/server/arch.txt
doc/*.txt
# ignore all .txt files in the doc/ directory
doc/**/*.txt
Содержание
-
История и внутреннее устройство
-
Локальный репозиторий
-
Практика
-
Удаленный репозиторий
-
Продвинутые команды

Удаленный репозиторий
Удаленный репозиторий

Удаленный репозиторий
$ git clone https://github.com/sorokin/cpp-course.git cpp_course
$ git remote
origin
$ git remote add upstream https://github.com/paulboone/ticgit
$ git remote
origin
upstream
$ git fetch upstream
$ git push origin master
$ git remote show origin
* remote origin
Fetch URL: https://github.com/schacon/ticgit
Push URL: https://github.com/schacon/ticgit
HEAD branch: master
Remote branches:
master tracked
................
Удаленный репозиторий

Жизненный цикл


Содержание
-
История и внутреннее устройство
-
Локальный репозиторий
-
Практика
-
Удаленный репозиторий
-
Продвинутые команды





deck
By Eugene Nemchenko
deck
- 1,133