Git: Книга от сообщества | Participants
|
- Statistics
- Participants
- Translate into Russian
- Translation result
- 74% translated in draft. Almost done, let's finish it!
If you do not want to register an account, you can sign in with OpenID.
See what files `git-submodule` created: | Посмотрим какие файлы были созданы после `git-submodule`: | |
$ ls -a | ||
. .. .git .gitmodules a b c d | ||
The `git-submodule add` command does a couple of things: | ||
- It clones the submodule under the current directory and by default checks out | - Она клонирует подмодули под текущую директорию и по умолчанию закрепляет их | |
the master branch. | ||
- It adds the submodule's clone path to the linkgit:gitmodules[5] file and | - Она добавляет linkgit:gitmodules[5] файл к пути клонированных подмодулей и | |
adds this file to the index, ready to be committed. | добавляет этот файл к индексу, готового для фиксации. | |
- It adds the submodule's current commit ID to the index, ready to be | - Она добавляет текущий ID фиксации подмодуля к индексу, готового | |
committed. | ||
Commit the superproject: | Для фиксации главного проекта необходимо ввести следующее: | |
$ git commit -m "Add submodules a, b, c and d." | ||
Now clone the superproject: | ||
$ cd .. | ||
$ git clone super cloned | ||
$ cd cloned | ||
The submodule directories are there, but they're empty: | Здесь находятся директории подмодулей, но они пусты: | |
$ ls -a a | ||
. .. | ||
$ git submodule status | ||
-d266b9873ad50488163457f025db7cdd9683d88b a | ||
-e81d457da15309b4fef4249aba9b50187999670d b | ||
-c1536a972b9affea0f16e0680ba87332dc059146 c | ||
-d96249ff5d57de5de093e6baff9e0aafa5276a74 d | ||
NOTE: The commit object names shown above would be different for you, but they | Внимание: Наименование объектов фиксации, отображаемых сверху, будут отличается от ваших, но они | |
should match the HEAD commit object names of your repositories. You can check | должны совпадать в ГОЛОВНЫМ наименованиями объектов фиксации вашего репозитория. Вы можете проверить | |
it by running `git ls-remote ../git/a`. | ||
Pulling down the submodules is a two-step process. First run `git submodule | Выталкивание подмодулей - это двух-шаговый процесс. | |
init` to add the submodule repository URLs to `.git/config`: | `git submodule init`для добавления URL подмодуля репозитория в `.git/config`: | |
$ git submodule init | ||
Now use `git-submodule update` to clone the repositories and check out the | Теперь используем `git-submodule update` для клонирования репозитория и закрепления | |
commits specified in the superproject: | ||
$ git submodule update | ||
$ cd a | ||
$ ls -a | ||
. .. .git a.txt | ||
One major difference between `git-submodule update` and `git-submodule add` is | Одно из главных отличий между `git-submodule update` и `git-submodule add` это то, | |
that `git-submodule update` checks out a specific commit, rather than the tip | что `git-submodule update` закрепляет указанную фиксацию, отличную от вершины | |
of a branch. It's like checking out a tag: the head is detached, so you're not | ветки. Это как закрепление метки: голова отделяется и таким образом вы не | |
working on a branch. | ||
$ git branch | ||
* (no branch) | ||
master | ||
If you want to make a change within a submodule and you have a detached head, | Если вы хотите внести изменения в подмодуль и уже отделили голову, | |
then you should create or checkout a branch, make your changes, publish the | тогда вам следует создать или закрепить ветвь, совершить свои изменения, внести | |
change within the submodule, and then update the superproject to reference the | их в подмодуль, и затем обновить главный проект для ссылки на новую | |
new commit: | ||
$ git checkout master | ||
or | ||
$ git checkout -b fix-up | ||
then | ||
$ echo "adding a line again" >> a.txt | ||
$ git commit -a -m "Updated the submodule from within the superproject." | $ git commit -a -m "Обновил подмодуль из главного проекта." | |
$ git push | ||
$ cd .. | ||
$ git diff | ||
diff --git a/a b/a | ||
index d266b98..261dfac 160000 | ||
--- a/a |
License: GPL
