1 # Git Magic - A guide to using Git
2 # This file is distributed under the GNU GENERAL PUBLIC LICENSE Version 3.
3 # Benn Lynn <benlynn@gmail.com>, 2007.
4 # Armin Stebich <armin@lordofbikes.de>, 2010.
7 "Project-Id-Version: Git Magic deutsch\n"
8 "Report-Msgid-Bugs-To: bennlynn@gmail.com\n"
9 "POT-Creation-Date: 2010-10-30 08:21+0300\n"
10 "PO-Revision-Date: 2010-10-26 18:38+0300\n"
11 "Last-Translator: Armin Stebich <armin@lordofbikes.de>\n"
12 "Language-Team: de <git-magic@lordofbikes.de>\n"
15 "Content-Type: text/plain; charset=UTF-8\n"
16 "Content-Transfer-Encoding: 8bit\n"
19 #: ../en/grandmaster.txt:2
20 msgid "== Git Grandmastery =="
24 #: ../en/grandmaster.txt:7
26 "By now, you should be able to navigate the *git help* pages and understand "
27 "almost everything. However, pinpointing the exact command required to solve "
28 "a given problem can be tedious. Perhaps I can save you some time: below are "
29 "some recipes I have needed in the past."
33 #: ../en/grandmaster.txt:9
34 msgid "=== Source Releases ==="
38 #: ../en/grandmaster.txt:12
40 "For my projects, Git tracks exactly the files I'd like to archive and "
41 "release to users. To create a tarball of the source code, I run:"
45 #: ../en/grandmaster.txt:14
47 msgid " $ git archive --format=tar --prefix=proj-1.2.3/ HEAD\n"
51 #: ../en/grandmaster.txt:16
52 msgid "=== Commit What Changed ==="
56 #: ../en/grandmaster.txt:19
58 "Telling Git when you've added, deleted and renamed files is troublesome for "
59 "certain projects. Instead, you can type:"
63 #: ../en/grandmaster.txt:22
71 #: ../en/grandmaster.txt:27
73 "Git will look at the files in the current directory and work out the details "
74 "by itself. Instead of the second add command, run `git commit -a` if you "
75 "also intend to commit at this time. See *git help ignore* for how to specify "
76 "files that should be ignored."
80 #: ../en/grandmaster.txt:29
81 msgid "You can perform the above in a single pass with:"
85 #: ../en/grandmaster.txt:31
87 msgid " $ git ls-files -d -m -o -z | xargs -0 git update-index --add --remove\n"
91 #: ../en/grandmaster.txt:35
93 "The *-z* and *-0* options prevent ill side-effects from filenames containing "
94 "strange characters. As this command adds ignored files, you may want to use "
95 "the `-x` or `-X` option."
99 #: ../en/grandmaster.txt:37
100 msgid "=== My Commit Is Too Big! ==="
104 #: ../en/grandmaster.txt:41
106 "Have you neglected to commit for too long? Been coding furiously and "
107 "forgotten about source control until now? Made a series of unrelated "
108 "changes, because that's your style?"
112 #: ../en/grandmaster.txt:43
113 msgid "No worries. Run:"
117 #: ../en/grandmaster.txt:45
119 msgid " $ git add -p\n"
123 #: ../en/grandmaster.txt:49
125 "For each edit you made, Git will show you the hunk of code that was changed, "
126 "and ask if it should be part of the next commit. Answer with \"y\" or \"n\". "
127 "You have other options, such as postponing the decision; type \"?\" to learn "
132 #: ../en/grandmaster.txt:51
133 msgid "Once you're satisfied, type"
137 #: ../en/grandmaster.txt:53
139 msgid " $ git commit\n"
143 #: ../en/grandmaster.txt:56
145 "to commit precisely the changes you selected (the 'staged' changes). Make "
146 "sure you omit the *-a* option, otherwise Git will commit all the edits."
150 #: ../en/grandmaster.txt:63
152 "What if you've edited many files in many places? Reviewing each change one "
153 "by one becomes frustratingly mind-numbing. In this case, use *git add -i*, "
154 "whose interface is less straightforward, but more flexible. With a few "
155 "keystrokes, you can stage or unstage several files at a time, or review and "
156 "select changes in particular files only. Alternatively, run *git commit \\--"
157 "interactive* which automatically commits after you're done."
161 #: ../en/grandmaster.txt:65
162 msgid "=== The Index: Git's Staging Area ==="
166 #: ../en/grandmaster.txt:71
168 "So far we have avoided Git's famous 'index', but we must now confront it to "
169 "explain the above. The index is a temporary staging area. Git seldom "
170 "shuttles data directly between your project and its history. Rather, Git "
171 "first writes data to the index, and then copies the data in the index to its "
176 #: ../en/grandmaster.txt:77
178 "For example, *commit -a* is really a two-step process. The first step places "
179 "a snapshot of the current state of every tracked file into the index. The "
180 "second step permanently records the snapshot now in the index. Committing "
181 "without the *-a* option only performs the second step, and only makes sense "
182 "after running commands that somehow change the index, such as *git add*."
186 #: ../en/grandmaster.txt:79
188 "Usually we can ignore the index and pretend we are reading straight from and "
189 "writing straight to the history. On this occasion, we want finer control, so "
190 "we manipulate the index. We place a snapshot of some, but not all, of our "
191 "changes into the index, and then permanently record this carefully rigged "
196 #: ../en/grandmaster.txt:81
197 msgid "=== Don't Lose Your HEAD ==="
201 #: ../en/grandmaster.txt:83
203 "The HEAD tag is like a cursor that normally points at the latest commit, "
204 "advancing with each new commit. Some Git commands let you move it. For "
209 #: ../en/grandmaster.txt:85
211 msgid " $ git reset HEAD~3\n"
215 #: ../en/grandmaster.txt:87
217 "will move the HEAD three commits back. Thus all Git commands now act as if "
218 "you hadn't made those last three commits, while your files remain in the "
219 "present. See the help page for some applications."
223 #: ../en/grandmaster.txt:89
225 "But how can you go back to the future? The past commits know nothing of the "
230 #: ../en/grandmaster.txt:91
231 msgid "If you have the SHA1 of the original HEAD then:"
235 #: ../en/grandmaster.txt:93
237 msgid " $ git reset 1b6d\n"
241 #: ../en/grandmaster.txt:95
243 "But suppose you never took it down? Don't worry: for commands like these, "
244 "Git saves the original HEAD as a tag called ORIG_HEAD, and you can return "
245 "safe and sound with:"
249 #: ../en/grandmaster.txt:97
251 msgid " $ git reset ORIG_HEAD\n"
255 #: ../en/grandmaster.txt:99
256 msgid "=== HEAD-hunting ==="
260 #: ../en/grandmaster.txt:101
262 "Perhaps ORIG_HEAD isn't enough. Perhaps you've just realized you made a "
263 "monumental mistake and you need to go back to an ancient commit in a long-"
268 #: ../en/grandmaster.txt:106
270 "By default, Git keeps a commit for at least two weeks, even if you ordered "
271 "Git to destroy the branch containing it. The trouble is finding the "
272 "appropriate hash. You could look at all the hash values in `.git/objects` "
273 "and use trial and error to find the one you want. But there's a much easier "
278 #: ../en/grandmaster.txt:108
280 "Git records every hash of a commit it computes in `.git/logs`. The "
281 "subdirectory `refs` contains the history of all activity on all branches, "
282 "while the file `HEAD` shows every hash value it has ever taken. The latter "
283 "can be used to find hashes of commits on branches that have been "
284 "accidentally lopped off."
288 #: ../en/grandmaster.txt:110
290 "The reflog command provides a friendly interface to these log files. Try"
294 #: ../en/grandmaster.txt:112
296 msgid " $ git reflog\n"
300 #: ../en/grandmaster.txt:114
301 msgid "Instead of cutting and pasting hashes from the reflog, try:"
305 #: ../en/grandmaster.txt:116
307 msgid " $ git checkout \"@{10 minutes ago}\"\n"
311 #: ../en/grandmaster.txt:118
312 msgid "Or checkout the 5th-last visited commit via:"
316 #: ../en/grandmaster.txt:120
318 msgid " $ git checkout \"@{5}\"\n"
322 #: ../en/grandmaster.txt:122
324 "See the ``Specifying Revisions'' section of *git help rev-parse* for more."
328 #: ../en/grandmaster.txt:125
330 "You may wish to configure a longer grace period for doomed commits. For "
335 #: ../en/grandmaster.txt:127
337 msgid " $ git config gc.pruneexpire \"30 days\"\n"
341 #: ../en/grandmaster.txt:130
343 "means a deleted commit will only be permanently lost once 30 days have "
344 "passed and *git gc* is run."
348 #: ../en/grandmaster.txt:132
349 msgid "You may also wish to disable automatic invocations of *git gc*:"
353 #: ../en/grandmaster.txt:134
355 msgid " $ git config gc.auto 0\n"
359 #: ../en/grandmaster.txt:136
361 "in which case commits will only be deleted when you run *git gc* manually."
365 #: ../en/grandmaster.txt:138
366 msgid "=== Building On Git ==="
370 #: ../en/grandmaster.txt:140
372 "In true UNIX fashion, Git's design allows it to be easily used as a low-"
373 "level component of other programs, such as GUI and web interfaces, "
374 "alternative command-line interfaces, patch managements tools, importing and "
375 "conversion tools and so on. In fact, some Git commands are themselves "
376 "scripts standing on the shoulders of giants. With a little tinkering, you "
377 "can customize Git to suit your preferences."
381 #: ../en/grandmaster.txt:143
383 "One easy trick is to use built-in Git aliases to shorten your most "
384 "frequently used commands:"
388 #: ../en/grandmaster.txt:148
391 " $ git config --global alias.co checkout\n"
392 " $ git config --global --get-regexp alias # display current aliases\n"
393 " alias.co checkout\n"
394 " $ git co foo # same as 'git checkout foo'\n"
398 #: ../en/grandmaster.txt:151
400 "Another is to print the current branch in the prompt, or window title. "
405 #: ../en/grandmaster.txt:153
407 msgid " $ git symbolic-ref HEAD\n"
411 #: ../en/grandmaster.txt:156
413 "shows the current branch name. In practice, you most likely want to remove "
414 "the \"refs/heads/\" and ignore errors:"
418 #: ../en/grandmaster.txt:158
420 msgid " $ git symbolic-ref HEAD 2> /dev/null | cut -b 12-\n"
424 #: ../en/grandmaster.txt:162
426 "The +contrib+ subdirectory is a treasure trove of tools built on Git. In "
427 "time, some of them may be promoted to official commands. On Debian and "
428 "Ubuntu, this directory lives at +/usr/share/doc/git-core/contrib+."
432 #: ../en/grandmaster.txt:164
434 "One popular resident is +workdir/git-new-workdir+. Via clever symlinking, "
435 "this script creates a new working directory whose history is shared with the "
436 "original repository:"
440 #: ../en/grandmaster.txt:166
442 msgid " $ git-new-workdir an/existing/repo new/directory\n"
446 #: ../en/grandmaster.txt:168
448 "The new directory and the files within can be thought of as a clone, except "
449 "since the history is shared, the two trees automatically stay in sync. "
450 "There's no need to merge, push, or pull."
454 #: ../en/grandmaster.txt:170
455 msgid "=== Daring Stunts ==="
459 #: ../en/grandmaster.txt:174
461 "These days, Git makes it difficult for the user to accidentally destroy "
462 "data. But if you know what you are doing, you can override safeguards for "
467 #: ../en/grandmaster.txt:176
469 msgid "*Checkout*: Uncommitted changes cause checkout to fail. To destroy your changes, and checkout a given commit anyway, use the force flag:\n"
473 #: ../en/grandmaster.txt:178
475 msgid " $ git checkout -f HEAD^\n"
479 #: ../en/grandmaster.txt:180
481 "On the other hand, if you specify particular paths for checkout, then there "
482 "are no safety checks. The supplied paths are quietly overwritten. Take care "
483 "if you use checkout in this manner."
487 #: ../en/grandmaster.txt:182
489 msgid "*Reset*: Reset also fails in the presence of uncommitted changes. To force it through, run:\n"
493 #: ../en/grandmaster.txt:184
495 msgid " $ git reset --hard 1b6d\n"
499 #: ../en/grandmaster.txt:186
501 msgid "*Branch*: Deleting branches fails if this causes changes to be lost. To force a deletion, type:\n"
505 #: ../en/grandmaster.txt:188
507 msgid " $ git branch -D dead_branch # instead of -d\n"
511 #: ../en/grandmaster.txt:190
513 "Similarly, attempting to overwrite a branch via a move fails if data loss "
514 "would ensue. To force a branch move, type:"
518 #: ../en/grandmaster.txt:192
520 msgid " $ git branch -M source target # instead of -m\n"
524 #: ../en/grandmaster.txt:197
526 "Unlike checkout and reset, these two commands defer data destruction. The "
527 "changes are still stored in the .git subdirectory, and can be retrieved by "
528 "recovering the appropriate hash from `.git/logs` (see \"HEAD-hunting\" "
529 "above). By default, they will be kept for at least two weeks."
533 #: ../en/grandmaster.txt:201
536 "*Clean*: Some git commands refuse to proceed because they're worried about\n"
537 "clobbering untracked files. If you're certain that all untracked files and\n"
538 "directories are expendable, then delete them mercilessly with:\n"
542 #: ../en/grandmaster.txt:203
544 msgid " $ git clean -f -d\n"
548 #: ../en/grandmaster.txt:205
549 msgid "Next time, that pesky command will work!"
553 #: ../en/grandmaster.txt:207
554 msgid "=== Preventing Bad Commits ==="
558 #: ../en/grandmaster.txt:212
560 "Stupid mistakes pollute my repositories. Most frightening are missing files "
561 "due to a forgotten *git add*. Lesser transgressions are trailing whitespace "
562 "and unresolved merge conflicts: though harmless, I wish these never appeared "
563 "on the public record."
567 #: ../en/grandmaster.txt:214
569 "If only I had bought idiot insurance by using a _hook_ to alert me about "
574 #: ../en/grandmaster.txt:217
578 " $ cp pre-commit.sample pre-commit # Older Git versions: chmod +x pre-commit\n"
582 #: ../en/grandmaster.txt:220
584 "Now Git aborts a commit if useless whitespace or unresolved merge conflicts "
589 #: ../en/grandmaster.txt:223
591 "For this guide, I eventually added the following to the beginning of the "
592 "*pre-commit* hook to guard against absent-mindedness:"
596 #: ../en/grandmaster.txt:228
599 " if git ls-files -o | grep '\\.txt$'; then\n"
600 " echo FAIL! Untracked .txt files.\n"
606 #: ../en/grandmaster.txt:232
608 "Several git operations support hooks; see *git help hooks*. We activated the "
609 "sample *post-update* hook earlier when discussing Git over HTTP. This runs "
610 "whenever the head moves. The sample post-update script updates files Git "
611 "needs for communication over Git-agnostic transports such as HTTP."