Git: Книга от сообщества

Scott Chacon, “Git Community Book”, public translation into Russian from English More about this translation.

See also 15 similar translations

Translate into another language.

Participants

saturn7215815 points
friskymutt4883 points
ivan.borzenkov1099 points
And others...
Join Translated.by to translate! If you already have a Translated.by account, please sign in.
If you do not want to register an account, you can sign in with OpenID.
Pages: previous Ctrl next next untranslated

See what files `git-submodule` created:

Посмотрим какие файлы были созданы после `git-submodule`:

History of edits (Latest: lexich121 8 months, 3 weeks ago) §

$ ls -a

$ ls -a

History of edits (Latest: lexich121 8 months, 3 weeks ago) §

. .. .git .gitmodules a b c d

. .. .git .gitmodules a b c d

History of edits (Latest: lexich121 8 months, 3 weeks ago) §

The `git-submodule add` command does a couple of things:

Команда `git-submodule add` делает следующее:

History of edits (Latest: lexich121 8 months, 3 weeks ago) §

- It clones the submodule under the current directory and by default checks out

- Она клонирует подмодули под текущую директорию и по умолчанию закрепляет их

History of edits (Latest: lexich121 8 months, 3 weeks ago) §

the master branch.

за главной веткой проекта.

History of edits (Latest: lexich121 8 months, 3 weeks ago) §

- It adds the submodule's clone path to the linkgit:gitmodules[5] file and

- Она добавляет linkgit:gitmodules[5] файл к пути клонированных подмодулей и

History of edits (Latest: lexich121 8 months, 3 weeks ago) §

adds this file to the index, ready to be committed.

добавляет этот файл к индексу, готового для фиксации.

History of edits (Latest: lexich121 8 months, 3 weeks ago) §

- It adds the submodule's current commit ID to the index, ready to be

- Она добавляет текущий ID фиксации подмодуля к индексу, готового

History of edits (Latest: lexich121 8 months, 3 weeks ago) §

committed.

для фиксации.

History of edits (Latest: lexich121 8 months, 3 weeks ago) §

Commit the superproject:

Для фиксации главного проекта необходимо ввести следующее:

History of edits (Latest: friskymutt 2 weeks, 2 days ago) §

$ git commit -m "Add submodules a, b, c and d."

$ git commit -m "Add submodules a, b, c and d."

History of edits (Latest: lexich121 8 months, 3 weeks ago) §

Now clone the superproject:

Теперь сделаем клон главного проекта:

History of edits (Latest: friskymutt 2 weeks, 2 days ago) §

$ cd ..

$ cd ..

History of edits (Latest: lexich121 8 months, 3 weeks ago) §

$ git clone super cloned

$ git clone super cloned

History of edits (Latest: lexich121 8 months, 3 weeks ago) §

$ cd cloned

$ cd cloned

History of edits (Latest: lexich121 8 months, 3 weeks ago) §

The submodule directories are there, but they're empty:

Здесь находятся директории подмодулей, но они пусты:

History of edits (Latest: lexich121 8 months, 3 weeks ago) §

$ ls -a a

$ ls -a a

History of edits (Latest: lexich121 8 months, 3 weeks ago) §

. ..

. ..

History of edits (Latest: lexich121 8 months, 3 weeks ago) §

$ git submodule status

$ git submodule status

History of edits (Latest: lexich121 8 months, 3 weeks ago) §

-d266b9873ad50488163457f025db7cdd9683d88b a

-d266b9873ad50488163457f025db7cdd9683d88b a

History of edits (Latest: lexich121 8 months, 3 weeks ago) §

-e81d457da15309b4fef4249aba9b50187999670d b

-e81d457da15309b4fef4249aba9b50187999670d b

History of edits (Latest: lexich121 8 months, 3 weeks ago) §

-c1536a972b9affea0f16e0680ba87332dc059146 c

-c1536a972b9affea0f16e0680ba87332dc059146 c

History of edits (Latest: lexich121 8 months, 3 weeks ago) §

-d96249ff5d57de5de093e6baff9e0aafa5276a74 d

-d96249ff5d57de5de093e6baff9e0aafa5276a74 d

History of edits (Latest: lexich121 8 months, 3 weeks ago) §

NOTE: The commit object names shown above would be different for you, but they

Внимание: Наименование объектов фиксации, отображаемых сверху, будут отличается от ваших, но они

History of edits (Latest: lexich121 8 months, 3 weeks ago) §

should match the HEAD commit object names of your repositories. You can check

должны совпадать в ГОЛОВНЫМ наименованиями объектов фиксации вашего репозитория. Вы можете проверить

History of edits (Latest: lexich121 8 months, 3 weeks ago) §

it by running `git ls-remote ../git/a`.

это запустив `git ls-remote ../git/a`.

History of edits (Latest: lexich121 8 months, 3 weeks ago) §

Pulling down the submodules is a two-step process. First run `git submodule

Выталкивание подмодулей - это двух-шаговый процесс.
Первоначально запускаем

History of edits (Latest: lexich121 8 months, 3 weeks ago) §

init` to add the submodule repository URLs to `.git/config`:

`git submodule init`для добавления URL подмодуля репозитория в `.git/config`:

History of edits (Latest: lexich121 8 months, 3 weeks ago) §

$ git submodule init

$ git submodule init

History of edits (Latest: lexich121 8 months, 3 weeks ago) §

Now use `git-submodule update` to clone the repositories and check out the

Теперь используем `git-submodule update` для клонирования репозитория и закрепления

History of edits (Latest: lexich121 8 months, 3 weeks ago) §

commits specified in the superproject:

указанной фиксации в главном проекте:

History of edits (Latest: friskymutt 2 weeks, 2 days ago) §

$ git submodule update

$ git submodule update

History of edits (Latest: lexich121 8 months, 3 weeks ago) §

$ cd a

$ cd a

History of edits (Latest: lexich121 8 months, 3 weeks ago) §

$ ls -a

$ ls -a

History of edits (Latest: lexich121 8 months, 3 weeks ago) §

. .. .git a.txt

. .. .git a.txt

History of edits (Latest: lexich121 8 months, 3 weeks ago) §

One major difference between `git-submodule update` and `git-submodule add` is

Одно из главных отличий между `git-submodule update` и `git-submodule add` это то,

History of edits (Latest: lexich121 8 months, 3 weeks ago) §

that `git-submodule update` checks out a specific commit, rather than the tip

что `git-submodule update` закрепляет указанную фиксацию, отличную от вершины

History of edits (Latest: lexich121 8 months, 3 weeks ago) §

of a branch. It's like checking out a tag: the head is detached, so you're not

ветки. Это как закрепление метки: голова отделяется и таким образом вы не

History of edits (Latest: friskymutt 2 weeks, 2 days ago) §

working on a branch.

работаете с веткой.

History of edits (Latest: friskymutt 2 weeks, 2 days ago) §

$ git branch

$ git branch

History of edits (Latest: friskymutt 2 weeks, 2 days ago) §

* (no branch)

* (no branch)

History of edits (Latest: friskymutt 2 weeks, 2 days ago) §

master

master

History of edits (Latest: friskymutt 2 weeks, 2 days ago) §

If you want to make a change within a submodule and you have a detached head,

Если вы хотите внести изменения в подмодуль и уже отделили голову,

History of edits (Latest: friskymutt 2 weeks, 2 days ago) §

then you should create or checkout a branch, make your changes, publish the

тогда вам следует создать или закрепить ветвь, совершить свои изменения, внести

History of edits (Latest: friskymutt 2 weeks, 2 days ago) §

change within the submodule, and then update the superproject to reference the

их в подмодуль, и затем обновить главный проект для ссылки на новую

History of edits (Latest: friskymutt 2 weeks, 2 days ago) §

new commit:

фиксацию (коммит):

History of edits (Latest: friskymutt 2 weeks, 2 days ago) §

$ git checkout master

$ git checkout master

History of edits (Latest: friskymutt 2 weeks, 2 days ago) §

or

или

History of edits (Latest: friskymutt 2 weeks, 2 days ago) §

$ git checkout -b fix-up

$ git checkout -b fix-up

History of edits (Latest: friskymutt 2 weeks, 2 days ago) §

then

затем

History of edits (Latest: friskymutt 2 weeks, 2 days ago) §

$ echo "adding a line again" >> a.txt

$ echo "снова добавляю строку" >> a.txt

History of edits (Latest: friskymutt 2 weeks, 2 days ago) §

$ git commit -a -m "Updated the submodule from within the superproject."

$ git commit -a -m "Обновил подмодуль из главного проекта."

History of edits (Latest: friskymutt 2 weeks, 2 days ago) §

$ git push

$ git push

History of edits (Latest: friskymutt 2 weeks, 2 days ago) §

$ cd ..

$ cd ..

History of edits (Latest: friskymutt 2 weeks, 2 days ago) §

$ git diff

$ git diff

History of edits (Latest: friskymutt 2 weeks, 2 days ago) §

diff --git a/a b/a

diff --git a/a b/a

History of edits (Latest: friskymutt 2 weeks, 2 days ago) §

index d266b98..261dfac 160000

index d266b98..261dfac 160000

History of edits (Latest: friskymutt 2 weeks, 2 days ago) §

--- a/a

--- a/a

History of edits (Latest: friskymutt 2 weeks, 2 days ago) §
Pages: previous Ctrl next next untranslated

License: GPL