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"
20 msgid "== Branch Wizardry =="
26 "Instant branching and merging are the most lethal of Git's killer features."
33 "*Problem*: External factors inevitably necessitate context switching. A severe\n"
34 "bug manifests in the released version without warning. The deadline for a\n"
35 "certain feature is moved closer. A developer whose help you need for a key section of the project is about to leave. In all cases, you must abruptly drop what you are doing and focus on a completely different task.\n"
39 #: ../en/branch.txt:10
41 "Interrupting your train of thought can be detrimental to your productivity, "
42 "and the more cumbersome it is to switch contexts, the greater the loss. With "
43 "centralized version control we must download a fresh working copy from the "
44 "central server. Distributed systems fare better, as we can clone the desired "
49 #: ../en/branch.txt:12
51 "But cloning still entails copying the whole working directory as well as the "
52 "entire history up to the given point. Even though Git reduces the cost of "
53 "this with file sharing and hard links, the project files themselves must be "
54 "recreated in their entirety in the new working directory."
58 #: ../en/branch.txt:14
60 msgid "*Solution*: Git has a better tool for these situations that is much faster and more space-efficient than cloning: *git branch*.\n"
64 #: ../en/branch.txt:16
66 "With this magic word, the files in your directory suddenly shapeshift from "
67 "one version to another. This transformation can do more than merely go back "
68 "or forward in history. Your files can morph from the last release to the "
69 "experimental version to the current development version to your friend's "
74 #: ../en/branch.txt:18
75 msgid "=== The Boss Key ==="
79 #: ../en/branch.txt:20
81 "Ever played one of those games where at the push of a button (``the boss "
82 "key''), the screen would instantly display a spreadsheet or something? So if "
83 "the boss walked in the office while you were playing the game you could "
84 "quickly hide it away?"
88 #: ../en/branch.txt:22
89 msgid "In some directory:"
93 #: ../en/branch.txt:27
96 " $ echo \"I'm smarter than my boss\" > myfile.txt\n"
99 " $ git commit -m \"Initial commit\"\n"
103 #: ../en/branch.txt:29
105 "We have created a Git repository that tracks one text file containing a "
106 "certain message. Now type:"
110 #: ../en/branch.txt:33
113 " $ git checkout -b boss # nothing seems to change after this\n"
114 " $ echo \"My boss is smarter than me\" > myfile.txt\n"
115 " $ git commit -a -m \"Another commit\"\n"
119 #: ../en/branch.txt:35
121 "It looks like we've just overwritten our file and committed it. But it's an "
126 #: ../en/branch.txt:37
128 msgid " $ git checkout master # switch to original version of the file\n"
132 #: ../en/branch.txt:39
134 "and hey presto! The text file is restored. And if the boss decides to snoop "
135 "around this directory, type:"
139 #: ../en/branch.txt:41
141 msgid " $ git checkout boss # switch to version suitable for boss' eyes\n"
145 #: ../en/branch.txt:43
147 "You can switch between the two versions of the file as much as you like, and "
148 "commit to each independently."
152 #: ../en/branch.txt:45
153 msgid "=== Dirty Work ==="
157 #: ../en/branch.txt:48
159 "[[branch]] Say you're working on some feature, and for some reason, you need "
160 "to go back three versions and temporarily put in a few print statements to "
161 "see how something works. Then:"
165 #: ../en/branch.txt:51
169 " $ git checkout HEAD~3\n"
173 #: ../en/branch.txt:53
175 "Now you can add ugly temporary code all over the place. You can even commit "
176 "these changes. When you're done,"
180 #: ../en/branch.txt:55
182 msgid " $ git checkout master\n"
186 #: ../en/branch.txt:57
188 "to return to your original work. Observe that any uncommitted changes are "
193 #: ../en/branch.txt:59
194 msgid "What if you wanted to save the temporary changes after all? Easy:"
198 #: ../en/branch.txt:61
200 msgid " $ git checkout -b dirty\n"
204 #: ../en/branch.txt:63
206 "and commit before switching back to the master branch. Whenever you want to "
207 "return to the dirty changes, simply type:"
211 #: ../en/branch.txt:65
213 msgid " $ git checkout dirty\n"
217 #: ../en/branch.txt:67
219 "We touched upon this command in an earlier chapter, when discussing loading "
220 "old states. At last we can tell the whole story: the files change to the "
221 "requested state, but we must leave the master branch. Any commits made from "
222 "now on take your files down a different road, which can be named later."
226 #: ../en/branch.txt:69
228 "In other words, after checking out an old state, Git automatically puts you "
229 "in a new, unnamed branch, which can be named and saved with *git checkout -"
234 #: ../en/branch.txt:71
235 msgid "=== Quick Fixes ==="
239 #: ../en/branch.txt:73
241 "You're in the middle of something when you are told to drop everything and "
242 "fix a newly discovered bug in commit `1b6d...`:"
246 #: ../en/branch.txt:76
250 " $ git checkout -b fixes 1b6d\n"
254 #: ../en/branch.txt:78
255 msgid "Then once you've fixed the bug:"
259 #: ../en/branch.txt:82
262 " $ git commit -a -m \"Bug fixed\"\n"
263 " $ git push # to the central repository\n"
264 " $ git checkout master\n"
268 #: ../en/branch.txt:84
269 msgid "and resume work on your original task."
273 #: ../en/branch.txt:86
274 msgid "You can even 'merge' in the bugfix you just made, either by typing:"
278 #: ../en/branch.txt:88
280 msgid " $ git merge fixes\n"
284 #: ../en/branch.txt:90
289 #: ../en/branch.txt:92
291 msgid " $ git pull\n"
295 #: ../en/branch.txt:94
296 msgid "since you have already pushed the bugfix to the main repository."
300 #: ../en/branch.txt:96
301 msgid "=== Merging ==="
305 #: ../en/branch.txt:100
307 "With some version control systems, creating branches is easy but merging "
308 "them back together is tough. With Git, merging is so trivial that you might "
309 "be unaware of it happening."
313 #: ../en/branch.txt:106
315 "We actually encountered merging long ago. The *pull* command in fact "
316 "'fetches' commits and then merges them into your current branch. If you have "
317 "no local changes, then the merge is a 'fast forward', a degenerate case akin "
318 "to fetching the latest version in a centralized version control system. But "
319 "if you do have local changes, Git will automatically merge, and report any "
324 #: ../en/branch.txt:111
326 "Ordinarily, a commit has exactly one 'parent commit', namely, the previous "
327 "commit. Merging branches together produces a commit with at least two "
328 "parents. This begs the question: what commit does `HEAD~10` really refer "
329 "to? A commit could have multiple parents, so which one do we follow?"
333 #: ../en/branch.txt:116
335 "It turns out this notation chooses the first parent every time. This is "
336 "desirable because the current branch becomes the first parent during a "
337 "merge; frequently you're only concerned with the changes you made in the "
338 "current branch, as opposed to changes merged in from other branches."
342 #: ../en/branch.txt:119
344 "You can refer to a specific parent with a caret. For example, to show the "
345 "logs from the second parent:"
349 #: ../en/branch.txt:121
351 msgid " $ git log HEAD^2\n"
355 #: ../en/branch.txt:124
357 "You may omit the number for the first parent. For example, to show the "
358 "differences with the first parent:"
362 #: ../en/branch.txt:126
364 msgid " $ git diff HEAD^\n"
368 #: ../en/branch.txt:128
369 msgid "You can combine this notation with other types. For example:"
373 #: ../en/branch.txt:130
375 msgid " $ git checkout 1b6d^^2~10 -b ancient\n"
379 #: ../en/branch.txt:133
381 "starts a new branch ``ancient'' representing the state 10 commits back from "
382 "the second parent of the first parent of the commit starting with 1b6d."
386 #: ../en/branch.txt:135
387 msgid "=== Uninterrupted Workflow ==="
391 #: ../en/branch.txt:137
393 "Often in hardware projects, the second step of a plan must await the "
394 "completion of the first step. A car undergoing repairs might sit idly in a "
395 "garage until a particular part arrives from the factory. A prototype might "
396 "wait for a chip to be fabricated before construction can continue."
400 #: ../en/branch.txt:142
402 "Software projects can be similar. The second part of a new feature may have "
403 "to wait until the first part has been released and tested. Some projects "
404 "require your code to be reviewed before accepting it, so you might wait "
405 "until the first part is approved before starting the second part."
409 #: ../en/branch.txt:147
411 "Thanks to painless branching and merging, we can bend the rules and work on "
412 "Part II before Part I is officially ready. Suppose you have committed Part I "
413 "and sent it for review. Let's say you're in the `master` branch. Then branch "
418 #: ../en/branch.txt:149
420 msgid " $ git checkout -b part2\n"
424 #: ../en/branch.txt:153
426 "Next, work on Part II, committing your changes along the way. To err is "
427 "human, and often you'll want to go back and fix something in Part I. If "
428 "you're lucky, or very good, you can skip these lines."
432 #: ../en/branch.txt:159
435 " $ git checkout master # Go back to Part I.\n"
437 " $ git commit -a # Commit the fixes.\n"
438 " $ git checkout part2 # Go back to Part II.\n"
439 " $ git merge master # Merge in those fixes.\n"
443 #: ../en/branch.txt:161
444 msgid "Eventually, Part I is approved:"
448 #: ../en/branch.txt:166
451 " $ git checkout master # Go back to Part I.\n"
452 " $ submit files # Release to the world!\n"
453 " $ git merge part2 # Merge in Part II.\n"
454 " $ git branch -d part2\n"
458 #: ../en/branch.txt:168
460 "Now you're in the `master` branch again, with Part II in the working "
465 #: ../en/branch.txt:172
467 "It's easy to extend this trick for any number of parts. It's also easy to "
468 "branch off retroactively: suppose you belatedly realize you should have "
469 "created a branch 7 commits ago. Then type:"
473 #: ../en/branch.txt:176
476 " $ git branch -m master part2\n"
477 " $ # Rename \"master\" branch to \"part2\".\n"
478 " $ git checkout HEAD~7 -b master\n"
482 #: ../en/branch.txt:179
484 "The `master` branch now contains just Part I, and the `part2` branch "
489 #: ../en/branch.txt:181
490 msgid "=== Reorganizing a Medley ==="
494 #: ../en/branch.txt:183
496 "Perhaps you like to work on all aspects of a project in the same branch. You "
497 "want to keep works-in-progress to yourself and want others to see your "
498 "commits only when they have been neatly organized. Start a couple of "
503 #: ../en/branch.txt:186
506 " $ git checkout -b sanitized\n"
507 " $ git checkout -b medley\n"
511 #: ../en/branch.txt:188
513 "Next, work on anything: fix bugs, add features, add temporary code, and so "
514 "forth, committing often along the way. Then:"
518 #: ../en/branch.txt:191
521 " $ git checkout sanitized\n"
522 " $ git cherry-pick medley^^\n"
526 #: ../en/branch.txt:193
528 "applies the grandparent of the head commit of the ``medley'' branch to the "
529 "``sanitized'' branch. With appropriate cherry-picks you can construct a "
530 "branch that contains only permanent code, and has related commits grouped "
535 #: ../en/branch.txt:195
536 msgid "=== Managing Branches ==="
540 #: ../en/branch.txt:197
541 msgid "List all branches by typing:"
545 #: ../en/branch.txt:199
547 msgid " $ git branch\n"
551 #: ../en/branch.txt:202
553 "By default, you start in a branch named ``master''. Some advocate leaving "
554 "the ``master'' branch untouched and creating new branches for your own edits."
558 #: ../en/branch.txt:205
560 "The *-d* and *-m* options allow you to delete and move (rename) branches. "
561 "See *git help branch*."
565 #: ../en/branch.txt:210
567 "The ``master'' branch is a useful custom. Others may assume that your "
568 "repository has a branch with this name, and that it contains the official "
569 "version of your project. Although you can rename or obliterate the "
570 "``master'' branch, you might as well respect this convention."
574 #: ../en/branch.txt:212
575 msgid "=== Temporary Branches ==="
579 #: ../en/branch.txt:217
581 "After a while you may realize you are creating short-lived branches "
582 "frequently for similar reasons: every other branch merely serves to save the "
583 "current state so you can briefly hop back to an older state to fix a high-"
584 "priority bug or something."
588 #: ../en/branch.txt:222
590 "It's analogous to changing the TV channel temporarily to see what else is "
591 "on. But instead of pushing a couple of buttons, you have to create, check "
592 "out, merge, and delete temporary branches. Luckily, Git has a shortcut that "
593 "is as convenient as a TV remote control:"
597 #: ../en/branch.txt:224
599 msgid " $ git stash\n"
603 #: ../en/branch.txt:229
605 "This saves the current state in a temporary location (a 'stash') and "
606 "restores the previous state. Your working directory appears exactly as it "
607 "was before you started editing, and you can fix bugs, pull in upstream "
608 "changes, and so on. When you want to go back to the stashed state, type:"
612 #: ../en/branch.txt:231
614 msgid " $ git stash apply # You may need to resolve some conflicts.\n"
618 #: ../en/branch.txt:234
620 "You can have multiple stashes, and manipulate them in various ways. See *git "
621 "help stash*. As you may have guessed, Git maintains branches behind the "
622 "scenes to perform this magic trick."
626 #: ../en/branch.txt:236
627 msgid "=== Work How You Want ==="
631 #: ../en/branch.txt:240
633 "You might wonder if branches are worth the bother. After all, clones are "
634 "almost as fast, and you can switch between them with *cd* instead of "
635 "esoteric Git commands."
639 #: ../en/branch.txt:246
641 "Consider web browsers. Why support multiple tabs as well as multiple "
642 "windows? Because allowing both accommodates a wide variety of styles. Some "
643 "users like to keep only one browser window open, and use tabs for multiple "
644 "webpages. Others might insist on the other extreme: multiple windows with no "
645 "tabs anywhere. Others still prefer something in between."
649 #: ../en/branch.txt:250
651 "Branching is like tabs for your working directory, and cloning is like "
652 "opening a new browser window. These operations are fast and local, so why "
653 "not experiment to find the combination that best suits you? Git lets you "
654 "work exactly how you want."