Магия Git. Гроссмейстерство Git

Ben Lynn, “Git Magic. Git Grandmastery”, public translation into Russian from English More about this translation.

See also 19 similar translations

Translate into another language.

Participants

stroncium1501 points
mifistor325 points
eeight106 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
1 2 3 4 5

Git Magic. Git Grandmastery

Магия Git. Гроссмейстерство Git

History of edits (Latest: alco 2 years, 1 month ago) §

== Git Grandmastery ==

== Гроссмейстерство Git ==

History of edits (Latest: stroncium 2 years, 1 month ago) §

This pretentiously named page is my dumping ground for uncategorized Git tricks.

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

History of edits (Latest: stroncium 2 years, 1 month ago) §

— В названии нет пафоса. Он отнес это к одной из глав. stroncium

=== Source Releases ===

=== Релизы исходников ===

History of edits (Latest: stroncium 2 years, 1 month ago) §

For my projects, Git tracks exactly the files I'd like to archive and release to users. To create a tarball of the source code, I run:

В моих проектах Git управляет только теми файлами, которые я собираюсь архивировать и пускать в релиз. Чтобы создать тарбол с исходниками, я выполняю:

History of edits (Latest: alco 2 years, 1 month ago) §

$ git archive --format=tar --prefix=proj-1.2.3/ HEAD

$ git archive --format=tar --prefix=proj-1.2.3/ HEAD

History of edits (Latest: mifistor 2 years, 2 months ago) §

=== Commit What Changed ===

=== Зафиксируйте изменения ===

History of edits (Latest: Natamile 2 years, 1 month ago) §

Telling Git when you've added, deleted and renamed files is troublesome for

Вручную сообщать Git о том, что вы добавили, удалили или переименовали файлы, может стать непростой задачей

History of edits (Latest: alco 2 years, 1 month ago) §

certain projects. Instead, you can type:

в некоторых проектах. Вместо этого вы можете выполнить команды:

History of edits (Latest: stroncium 2 years, 1 month ago) §

$ git add .

$ git add .

History of edits (Latest: mifistor 2 years, 2 months ago) §

$ git add -u

$ git add -u

History of edits (Latest: mifistor 2 years, 2 months ago) §

Git will look at the files in the current directory and work out the details by itself. Instead of the second add command, run `git commit -a` if you also intend to commit at this time. See *git help ignore* for how to specify files that should be ignored.

Git просмотрит файлы в текущем каталоге и обработает изменения сам. Вместо второй команды add, выполните *git commit -a*, если вы хотите также сделать коммит с изменениями. В *git help ignore* можно посмотреть, как указать, какие файлы должны игнорироваться.

History of edits (Latest: stroncium 2 years, 1 month ago) §

You can perform the above in a single pass with:

Вы можете выполнить все это в один прием:

History of edits (Latest: stroncium 2 years, 1 month ago) §

$ git ls-files -d -m -o -z | xargs -0 git update-index --add --remove

$ git ls-files -d -m -o -z | xargs -0 git update-index --add --remove

History of edits (Latest: mifistor 2 years, 2 months ago) §

The *-z* and *-0* options prevent ill side-effects from filenames containing strange characters. As this command adds ignored files, you may want to use the `-x` or `-X` option.

Опции *-z* и *-0* предотвращают побочные эффекты от файловых имен, содержащих специальные символы. Поскольку эта команда добавляет игнорируемые файлы, вы можете использовать опции `-x` или `-X`.

History of edits (Latest: stroncium 2 years, 1 month ago) §

=== My Commit Is Too Big! ===

=== Слишком большой коммит ===

History of edits (Latest: stroncium 2 years, 1 month ago) §

Have you neglected to commit for too long? Been coding furiously and forgotten about source control until now? Made a series of unrelated changes, because that's your style?

Вы пренебрегали коммитами слишком долго? Яростно писали код и вспомнили о контроле исходников только сейчас? Внесли ряд несвязанных изменений, потому что это ваш стиль?

History of edits (Latest: stroncium 2 years, 1 month ago) §

No worries. Run:

Никаких проблем. Выполните:

History of edits (Latest: stroncium 2 years, 1 month ago) §

$ git add -p

$ git add -p

History of edits (Latest: mifistor 2 years, 2 months ago) §

For each edit you made, Git will show you the hunk of code that was changed, and ask if it should be part of the next commit. Answer with "y" or "n". You have other options, such as postponing the decision; type "?" to learn more.

Для каждого внесенного изменения Git покажет измененный участок кода и спросит, должно ли это изменение пройти в следующем коммите. Отвечаем "y" или "n". Если вы хотите сделать что-то другое, например отложить выбор, введите "?" чтобы получить дополнительную информацию.

History of edits (Latest: stroncium 2 years, 1 month ago) §

Once you're satisfied, type

Как только все будет готово, выполните:

History of edits (Latest: stroncium 2 years, 1 month ago) §

$ git commit

$ git commit

History of edits (Latest: mifistor 2 years, 2 months ago) §

to commit precisely the changes you selected (the 'staged' changes). Make sure you omit the *-a* option, otherwise Git will commit all the edits.

для коммита именно тех изменений, которые вы выбрали ('staged' изменения). Убедитесь, что вы не указали опцию *-a*, в противном случае Git добавит в коммит все изменения.

History of edits (Latest: stroncium 2 years, 1 month ago) §

What if you've edited many files in many places? Reviewing each change one by one becomes frustratingly mind-numbing. In this case, use *git add -i*, whose interface is less straightforward, but more flexible. With a few keystrokes, you can stage or unstage several files at a time, or review and select changes in particular files only. Alternatively, run *git commit \--interactive* which automatically commits after you're done.

Что делать, если вы изменили множество файлов во многих местах? Просмотр каждого отдельного изменения - удручающая задача. В этом случае используйте *git add -i*, чей интерфейс менее прост, но более гибок. При помощи нескольких нажатий кнопок можно добавить на этап или убрать с этапа несколько файлов одновременно, либо просмотреть и выделить изменения в отдельных файлах. Как вариант, запустите *git commit \--interactive*, который автоматически сделает коммит после того, как вы закончите.

History of edits (Latest: stroncium 2 years, 1 month ago) §
Pages: ← previous Ctrl next
1 2 3 4 5

License: GNU General Public License version 3