Skip to content
Browse files

some translations additions and a new post

  • Loading branch information...
1 parent a5378ae commit c588c011c878300fd40a76ab0d30a075f08393cc @schacon schacon committed Aug 25, 2010
View
241 _posts/tips/2010-08-25-notes.markdown
@@ -0,0 +1,241 @@
+---
+layout: post
+title: Note to Self
+---
+
+One of the cool things about Git is that it has strong cryptographic
+integrity. If you change any bit in the commit data or any of the files it
+keeps, all the checksums change, including the commit SHA and every commit
+SHA since that one. However, that means that in order to amend the commit
+in any way, for instance to add some comments on something or even sign off
+on a commit, you have to change the SHA of the commit itself.
+
+Wouldn't it be nice if you could add data to a commit without changing it's
+SHA? If only there existed an external mechanism to attach data to a commit
+without modifying the commit message itself. Happy day! It turns out there
+exists just such a feature in newer versions of Git! As we can see from the
+Git 1.6.6 release notes where this new functionality was first introduced:
+
+ * "git notes" command to annotate existing commits.
+
+Need any more be said? Well, maybe. How do you use it? What does it do?
+How can it be useful? I'm not sure I can answer all of these questions, but
+let's give it a try. First of all, how does one use it?
+
+Well, to add a note to a specific commit, you only need to run
+`git notes add [commit]`, like this:
+
+ $ git notes add HEAD
+
+This will open up your editor to write your commit message. You can also use
+the `-m` option to provide the note right on the command line:
+
+ $ git notes add -m 'I approve - Scott' master~1
+
+That will add a note to the first parent on the last commit on the master
+branch. Now, how to view these notes? The easiest way is with the `git log`
+command.
+
+
+ $ git log master
+ commit 0385bcc3bc66d1b1ec07346c237061574335c3b8
+ Author: Ryan Tomayko <rtomayko@gmail.com>
+ Date: Tue Jun 22 20:09:32 2010 -0700
+
+ yield to run block right before accepting connections
+
+ commit 06ca03a20bb01203e2d6b8996e365f46cb6d59bd
+ Author: Ryan Tomayko <rtomayko@gmail.com>
+ Date: Wed May 12 06:47:15 2010 -0700
+
+ no need to delete these header names now
+
+ Notes:
+ I approve - Scott
+
+You can see the notes appended automatically in the log output. You can only
+have one note per commit in a namespace though (I will explain namespaces in
+the next section), so if you want to add a note to that commit, you have to
+instead edit the existing one. You can either do this by running:
+
+ $ git notes edit master~1
+
+Which will open a text editor with the existing note so you can edit it:
+
+ I approve - Scott
+
+ #
+ # Write/edit the notes for the following object:
+ #
+ # commit 06ca03a20bb01203e2d6b8996e365f46cb6d59bd
+ # Author: Ryan Tomayko <rtomayko@gmail.com>
+ # Date: Wed May 12 06:47:15 2010 -0700
+ #
+ # no need to delete these header names now
+ #
+ # kidgloves.rb | 2 --
+ # 1 files changed, 0 insertions(+), 2 deletions(-)
+ ~
+ ~
+ ~
+ ".git/NOTES_EDITMSG" 13L, 338C
+
+Sort of weird, but it works. If you just want to add something to the end of
+an existing note, you can run `git notes append SHA`, but only in newer
+versions of Git (I think 1.7.1 and above).
+
+## Notes Namespaces ##
+
+Since you can only have one note per commit, Git allows you to have multiple
+namespaces for your notes. The default namespace is called 'commits', but
+you can change that. Let's say we're using the 'commits' notes namespace to
+store general comments but we want to also store bugzilla information for our
+commits. We can also have a 'bugzilla' namespace. Here is how we would add
+a bug number to a commit under the bugzilla namespace:
+
+ $ git notes --ref=bugzilla add -m 'bug #15' 0385bcc3
+
+However, now you have to tell Git to specifically look in that namespace:
+
+ $ git log --show-notes=bugzilla
+ commit 0385bcc3bc66d1b1ec07346c237061574335c3b8
+ Author: Ryan Tomayko <rtomayko@gmail.com>
+ Date: Tue Jun 22 20:09:32 2010 -0700
+
+ yield to run block right before accepting connections
+
+ Notes (bugzilla):
+ bug #15
+
+ commit 06ca03a20bb01203e2d6b8996e365f46cb6d59bd
+ Author: Ryan Tomayko <rtomayko@gmail.com>
+ Date: Wed May 12 06:47:15 2010 -0700
+
+ no need to delete these header names now
+
+ Notes:
+ I approve - Scott
+
+Notice that it also will show your normal notes. You can actually have it show
+notes from all your namespaces by running `git log --show-notes=*` - if you
+have a lot of them, you may want to just alias that. Here is what your log
+output might look like if you have a number of notes namespaces:
+
+ $ git log -1 --show-notes=*
+ commit 0385bcc3bc66d1b1ec07346c237061574335c3b8
+ Author: Ryan Tomayko <rtomayko@gmail.com>
+ Date: Tue Jun 22 20:09:32 2010 -0700
+
+ yield to run block right before accepting connections
+
+ Notes:
+ I approve of this, too - Scott
+
+ Notes (bugzilla):
+ bug #15
+
+ Notes (build):
+ build successful (8/13/10)
+
+You can also switch the current namespace you're using so that the default for
+writing and showing notes is not 'commits' but, say, 'bugzilla' instead. If you
+export the variable `GIT_NOTES_REF` to point to something different, then the
+`--ref` and `--show-notes` options are not neccesary. For example:
+
+ $ export GIT_NOTES_REF=refs/notes/bugzilla
+
+That will set your default to 'bugzilla' instead. It has to start with the 'refs/notes/' though.
+
+## Sharing Notes ##
+
+Now, here is where the general usability of this really breaks down. I am
+hoping that this will be improved in the future and I put off writing this post
+because of my concern with this phase of the process, but I figured it has
+interesting enough functionality as-is that someone might want to play with it.
+
+So, the notes (as you may have noticed in the previous section) are stored as
+references, just like branches and tags. This means you can push them to a
+server. However, Git has a bit of magic built in to expand a branch name
+like 'master' to what it really is, which is 'refs/heads/master'. Unfortunately,
+Git has no such magic built in for notes. So, to push your notes to a server,
+you cannot simply run something like `git push origin bugzilla`. Git will do
+this:
+
+ $ git push origin bugzilla
+ error: src refspec bugzilla does not match any.
+ error: failed to push some refs to 'git@github.com:schacon/kidgloves.git'
+
+However, you can push anything under 'refs/' to a server, you just need to be
+more explicit about it. If you run this it will work fine:
+
+ $ git push origin refs/notes/bugzilla
+ Counting objects: 3, done.
+ Delta compression using up to 2 threads.
+ Compressing objects: 100% (2/2), done.
+ Writing objects: 100% (3/3), 263 bytes, done.
+ Total 3 (delta 0), reused 0 (delta 0)
+ To git@github.com:schacon/kidgloves.git
+ * [new branch] refs/notes/bugzilla -> refs/notes/bugzilla
+
+In fact, you may want to just make that `git push origin refs/notes/*` which
+will push all your notes. This is what Git does normally for something like
+tags. When you run `git push origin --tags` it basically expands to
+`git push origin refs/tags/*`.
+
+Now we're going to get a bit esoteric - forgive me. A shortcut you can use is
+to add a `fetch` refspec to your `.git/config` file. If you look at your config
+file, it probably has a section that looks something like this:
+
+ [remote "origin"]
+ url = git@github.com:schacon/kidgloves.git
+ fetch = +refs/heads/*:refs/remotes/origin/*
+
+This means for the remote named 'origin', the URL to interact with is that
+github one and when you run 'git fetch origin', take all the branches under
+`refs/heads` on the server and put them into `refs/remotes/origin` locally.
+So, `master` on the server becomes `origin/master` locally. If you change
+that line to be:
+
+ fetch = +refs/heads/*:refs/remotes/manamana/*
+
+Then after the next `git fetch origin`, the 'master' branch on the server
+will be `manamana/master` locally. The '+' at the beginning means 'just
+blindly overwrite the values' - don't check for fast-forwardability.
+
+Now, the trick here for pushing notes easily is to add lines telling Git
+what you want it to do when you run `git push origin`. By default, Git
+will push every reference it has locally that the server also has (ie: it pushes
+all branches that have the same name on the server). You can overwrite this
+default by setting the `push.default` setting, which I prefer to have as 'matching' - I'm getting off topic now, I'll do another post on this later.
+
+Anyhow, you can tell git what you want it to do when you run `git push origin`
+by setting `push` lines in your config. If you add these lines:
+
+ push = refs/heads/*:refs/heads/*
+ push = refs/notes/*:refs/notes/scott/*
+
+Then when you run `git push origin`, Git will try to push all your local
+references up to be references on the server. (Don't put a '+' at the beginning,
+or it's like running `git push -f` every time). It will also push all your
+notes up to be namespaced by 'scott' on the server. So people will see your
+bugzilla notes as 'scott/bugzilla'. If you want everybody to use the same
+notes namespaces, just leave out the 'scott/'.
+
+You can also have Git fetch notes by default, which it also will not do. If
+you add this line to the same section:
+
+ fetch = +refs/notes/*:refs/notes/origin/*
+
+Then Git will also get all the notes on the server, and in this case namespace
+them with 'origin/'. The issue here is that then you have the 'bugzilla' note
+you made locally also under 'origin/scott/bugzilla' after you push it up and
+pull it back down again. This can get messy. However, the issue is that you
+need to be careful with these notes because they're super difficult to merge,
+which means if you create a note and push it, then someone else fetches and
+modifies it and in the meantime you also modify it, it's really hard to merge
+them together.
+
+Because of this, it's probably best to namespace your notes like I've shown or
+just have an automated process create them (like build statuses or bugzilla
+artifacts).
+
View
92 book/ch2-3.html
@@ -122,97 +122,7 @@ <h2 id='viewing_the_commit_history'>Viewing the Commit History</h2>
a11bef0 - Scott Chacon, 11 months ago : first commit</code></pre>
<p>Table 2-1 lists some of the more useful options that format takes.</p>
-
-<pre><code>Option Description of Output
-%H Commit hash
-%h Abbreviated commit hash
-%T Tree hash
-%t Abbreviated tree hash
-%P Parent hashes
-%p Abbreviated parent hashes
-%an Author name
-%ae Author e-mail
-%ad Author date (format respects the --date= option)
-%ar Author date, relative
-%cn Committer name
-%ce Committer email
-%cd Committer date
-%cr Committer date, relative
-%s Subject</code></pre>
-
-<p>You may be wondering what the difference is between <em>author</em> and <em>committer</em>. The author is the person who originally wrote the work, whereas the committer is the person who last applied the work. So, if you send in a patch to a project and one of the core members applies the patch, both of you get credit — you as the author and the core member as the committer. We’ll cover this distinction a bit more in Chapter 5.</p>
-
-<p>The oneline and format options are particularly useful with another <code>log</code> option called <code>--graph</code>. This option adds a nice little ASCII graph showing your branch and merge history, which we can see our copy of the Grit project repository:</p>
-
-<pre><code>$ git log --pretty=format:&quot;%h %s&quot; --graph
-* 2d3acf9 ignore errors from SIGCHLD on trap
-* 5e3ee11 Merge branch &#39;master&#39; of git://github.com/dustin/grit
-|\
-| * 420eac9 Added a method for getting the current branch.
-* | 30e367c timeout code and tests
-* | 5a09431 add timeout protection to grit
-* | e1193f8 support for heads with slashes in them
-|/
-* d6016bc require time for xmlschema
-* 11d191e Merge branch &#39;defunkt&#39; into local</code></pre>
-
-<p>Those are only some simple output-formatting options to <code>git log</code> — there are many more. Table 2-2 lists the options we’ve covered so far and some other common formatting options that may be useful, along with how they change the output of the log command.</p>
-
-<pre><code>Option Description
--p Show the patch introduced with each commit.
---stat Show statistics for files modified in each commit.
---shortstat Display only the changed/insertions/deletions line from the --stat command.
---name-only Show the list of files modified after the commit information.
---name-status Show the list of files affected with added/modified/deleted information as well.
---abbrev-commit Show only the first few characters of the SHA-1 checksum instead of all 40.
---relative-date Display the date in a relative format (for example, “2 weeks ago”) instead of using the full date format.
---graph Display an ASCII graph of the branch and merge history beside the log output.
---pretty Show commits in an alternate format. Options include oneline, short, full, fuller, and format (where you specify your own format).</code></pre>
-
-<h3 id='limiting_log_output'>Limiting Log Output</h3>
-
-<p>In addition to output-formatting options, git log takes a number of useful limiting options — that is, options that let you show only a subset of commits. You’ve seen one such option already — the <code>-2</code> option, which show only the last two commits. In fact, you can do <code>-&lt;n&gt;</code>, where <code>n</code> is any integer to show the last <code>n</code> commits. In reality, you’re unlikely to use that often, because Git by default pipes all output through a pager so you see only one page of log output at a time.</p>
-
-<p>However, the time-limiting options such as <code>--since</code> and <code>--until</code> are very useful. For example, this command gets the list of commits made in the last two weeks:</p>
-
-<pre><code>$ git log --since=2.weeks</code></pre>
-
-<p>This command works with lots of formats — you can specify a specific date (“2008-01-15”) or a relative date such as “2 years 1 day 3 minutes ago”.</p>
-
-<p>You can also filter the list to commits that match some search criteria. The <code>--author</code> option allows you to filter on a specific author, and the <code>--grep</code> option lets you search for keywords in the commit messages. (Note that if you want to specify both author and grep options, you have to add <code>--all-match</code> or the command will match commits with either.)</p>
-
-<p>The last really useful option to pass to <code>git log</code> as a filter is a path. If you specify a directory or file name, you can limit the log output to commits that introduced a change to those files. This is always the last option and is generally preceded by double dashes (<code>--</code>) to separate the paths from the options.</p>
-
-<p>In Table 2-3 we’ll list these and a few other common options for your reference.</p>
-
-<pre><code>Option Description
--(n) Show only the last n commits
---since, --after Limit the commits to those made after the specified date.
---until, --before Limit the commits to those made before the specified date.
---author Only show commits in which the author entry matches the specified string.
---committer Only show commits in which the committer entry matches the specified string.</code></pre>
-
-<p>For example, if you want to see which commits modifying test files in the Git source code history were committed by Junio Hamano and were not merges in the month of October 2008, you can run something like this:</p>
-
-<pre><code>$ git log --pretty=&quot;%h - %s&quot; --author=gitster --since=&quot;2008-10-01&quot; \
- --before=&quot;2008-11-01&quot; --no-merges -- t/
-5610e3b - Fix testcase failure when extended attribute
-acd3b9e - Enhance hold_lock_file_for_{update,append}()
-f563754 - demonstrate breakage of detached checkout wi
-d1a43f2 - reset --hard/read-tree --reset -u: remove un
-51a94af - Fix &quot;checkout --track -b newbranch&quot; on detac
-b0ad11e - pull: allow &quot;git pull origin $something:$cur</code></pre>
-
-<p>Of the nearly 20,000 commits in the Git source code history, this command shows the 6 that match those criteria.</p>
-
-<h3 id='using_a_gui_to_visualize_history'>Using a GUI to Visualize History</h3>
-
-<p>If you like to use a more graphical tool to visualize your commit history, you may want to take a look at a Tcl/Tk program called gitk that is distributed with Git. Gitk is basically a visual <code>git log</code> tool, and it accepts nearly all the filtering options that <code>git log</code> does. If you type gitk on the command line in your project, you should see something like Figure 2-2.</p>
-
-<p><center><img src="/figures/ch2/18333fig0202-tn.png"></center><br/> Figure 2-2. The gitk history visualizer.</p>
-
-<p>You can see the commit history in the top half of the window along with a nice ancestry graph. The diff viewer in the bottom half of the window shows you the changes introduced at any commit you click.</p>
-
+<hr />
<div id='nav'>
<a href='ch2-2.html'>prev</a> | <a href='ch2-4.html'>next</a>
</div>
View
84 book/ch2-4.html
@@ -1,88 +1,36 @@
---
layout: master
-title: Pro Git 2.4 Git Basics Undoing Things
+title: Pro Git 2.4 Git Basics Option Description of Output
---
-<h2 id='undoing_things'>Undoing Things</h2>
+<h2 id='option_description_of_output'>Option Description of Output</h2>
-<p>At any stage, you may want to undo something. Here, we’ll review a few basic tools for undoing changes that you’ve made. Be careful, because you can’t always undo some of these undos. This is one of the few areas in Git where you may lose some work if you do it wrong.</p>
+<p><code>%H</code> Commit hash</p>
-<h3 id='changing_your_last_commit'>Changing Your Last Commit</h3>
+<p><code>%h</code> Abbreviated commit hash</p>
-<p>One of the common undos takes place when you commit too early and possibly forget to add some files, or you mess up your commit message. If you want to try that commit again, you can run commit with the <code>--amend</code> option:</p>
+<p><code>%T</code> Tree hash</p>
-<pre><code>$ git commit --amend</code></pre>
+<p><code>%t</code> Abbreviated tree hash</p>
-<p>This command takes your staging area and uses it for the commit. If you’ve have made no changes since your last commit (for instance, you run this command immediately after your previous commit), then your snapshot will look exactly the same and all you’ll change is your commit message.</p>
+<p><code>%P</code> Parent hashes</p>
-<p>The same commit-message editor fires up, but it already contains the message of your previous commit. You can edit the message the same as always, but it overwrites your previous commit.</p>
+<p><code>%p</code> Abbreviated parent hashes</p>
-<p>As an example, if you commit and then realize you forgot to stage the changes in a file you wanted to add to this commit, you can do something like this:</p>
+<p><code>%an</code> Author name</p>
-<pre><code>$ git commit -m &#39;initial commit&#39;
-$ git add forgotten_file
-$ git commit --amend</code></pre>
+<p><code>%ae</code> Author e-mail</p>
-<p>All three of these commands end up with a single commit — the second commit replaces the results of the first.</p>
+<p><code>%ad</code> Author date (format respects the <code>--date=</code> option)</p>
-<h3 id='unstaging_a_staged_file'>Unstaging a Staged File</h3>
+<p><code>%ar</code> Author date, relative</p>
-<p>The next two sections demonstrate how to wrangle your staging area and working directory changes. The nice part is that the command you use to determine the state of those two areas also reminds you how to undo changes to them. For example, let’s say you’ve changed two files and want to commit them as two separate changes, but you accidentally type <code>git add *</code> and stage them both. How can you unstage one of the two? The <code>git status</code> command reminds you:</p>
+<p><code>%cn</code> Committer name</p>
-<pre><code>$ git add .
-$ git status
-# On branch master
-# Changes to be committed:
-# (use &quot;git reset HEAD &lt;file&gt;...&quot; to unstage)
-#
-# modified: README.txt
-# modified: benchmarks.rb
-#</code></pre>
+<p><code>%ce</code> Committer email</p>
-<p>Right below the “Changes to be committed” text, it says use <code>git reset HEAD &lt;file&gt;...</code> to unstage. So, let’s use that advice to unstage the benchmarks.rb file:</p>
+<p><code>%cd</code> Committer date</p>
-<pre><code>$ git reset HEAD benchmarks.rb
-benchmarks.rb: locally modified
-$ git status
-# On branch master
-# Changes to be committed:
-# (use &quot;git reset HEAD &lt;file&gt;...&quot; to unstage)
-#
-# modified: README.txt
-#
-# Changed but not updated:
-# (use &quot;git add &lt;file&gt;...&quot; to update what will be committed)
-# (use &quot;git checkout -- &lt;file&gt;...&quot; to discard changes in working directory)
-#
-# modified: benchmarks.rb
-#</code></pre>
-
-<p>The command is a bit strange, but it works. The benchmarks.rb file is modified but once again unstaged.</p>
-
-<h3 id='unmodifying_a_modified_file'>Unmodifying a Modified File</h3>
-
-<p>What if you realize that you don’t want to keep your changes to the benchmarks.rb file? How can you easily unmodify it — revert it back to what it looked like when you last committed (or initially cloned, or however you got it into your working directory)? Luckily, <code>git status</code> tells you how to do that, too. In the last example output, the unstaged area looks like this:</p>
-
-<pre><code># Changed but not updated:
-# (use &quot;git add &lt;file&gt;...&quot; to update what will be committed)
-# (use &quot;git checkout -- &lt;file&gt;...&quot; to discard changes in working directory)
-#
-# modified: benchmarks.rb
-#</code></pre>
-
-<p>It tells you pretty explicitly how to discard the changes you’ve made (at least, the newer versions of Git, 1.6.1 and later, do this — if you have an older version, we highly recommend upgrading it to get some of these nicer usability features). Let’s do what it says:</p>
-
-<pre><code>$ git checkout -- benchmarks.rb
-$ git status
-# On branch master
-# Changes to be committed:
-# (use &quot;git reset HEAD &lt;file&gt;...&quot; to unstage)
-#
-# modified: README.txt
-#</code></pre>
-
-<p>You can see that the changes have been reverted. You should also realize that this is a dangerous command: any changes you made to that file are gone — you just copied another file over it. Don’t ever use this command unless you absolutely know that you don’t want the file. If you just need to get it out of the way, we’ll go over stashing and branching in the next chapter; these are generally better ways to go.</p>
-
-<p>Remember, anything that is committed in Git can almost always be recovered. Even commits that were on branches that were deleted or commits that were overwritten with an <code>--amend</code> commit can be recovered (see Chapter 9 for data recovery). However, anything you lose that was never committed is likely never to be seen again.</p>
+<p><code>%cr</code> Committer date, relative</p>
<div id='nav'>
<a href='ch2-3.html'>prev</a> | <a href='ch2-5.html'>next</a>
View
152 book/ch2-5.html
@@ -1,145 +1,29 @@
---
layout: master
-title: Pro Git 2.5 Git Basics Working with Remotes
+title: Pro Git 2.5 Git Basics <code>%s</code> Subject
---
-<h2 id='working_with_remotes'>Working with Remotes</h2>
+<h2 id='_subject'><code>%s</code> Subject</h2>
-<p>To be able to collaborate on any Git project, you need to know how to manage your remote repositories. Remote repositories are versions of your project that are hosted on the Internet or network somewhere. You can have several of them, each of which generally is either read-only or read/write for you. Collaborating with others involves managing these remote repositories and pushing and pulling data to and from them when you need to share work. Managing remote repositories includes knowing how to add remote repositories, remove remotes that are no longer valid, manage various remote branches and define them as being tracked or not, and more. In this section, we’ll cover these remote-management skills.</p>
+<p>Table: Format options</p>
-<h3 id='showing_your_remotes'>Showing Your Remotes</h3>
+<p>You may be wondering what the difference is between <em>author</em> and <em>committer</em>. The author is the person who originally wrote the work, whereas the committer is the person who last applied the work. So, if you send in a patch to a project and one of the core members applies the patch, both of you get credit — you as the author and the core member as the committer. We’ll cover this distinction a bit more in Chapter 5.</p>
-<p>To see which remote servers you have configured, you can run the git remote command. It lists the shortnames of each remote handle you’ve specified. If you’ve cloned your repository, you should at least see origin — that is the default name Git gives to the server you cloned from:</p>
+<p>The oneline and format options are particularly useful with another <code>log</code> option called <code>--graph</code>. This option adds a nice little ASCII graph showing your branch and merge history, which we can see our copy of the Grit project repository:</p>
-<pre><code>$ git clone git://github.com/schacon/ticgit.git
-Initialized empty Git repository in /private/tmp/ticgit/.git/
-remote: Counting objects: 595, done.
-remote: Compressing objects: 100% (269/269), done.
-remote: Total 595 (delta 255), reused 589 (delta 253)
-Receiving objects: 100% (595/595), 73.31 KiB | 1 KiB/s, done.
-Resolving deltas: 100% (255/255), done.
-$ cd ticgit
-$ git remote
-origin</code></pre>
-
-<p>You can also specify <code>-v</code>, which shows you the URL that Git has stored for the shortname to be expanded to:</p>
-
-<pre><code>$ git remote -v
-origin git://github.com/schacon/ticgit.git</code></pre>
-
-<p>If you have more than one remote, the command lists them all. For example, my Grit repository looks something like this.</p>
-
-<pre><code>$ cd grit
-$ git remote -v
-bakkdoor git://github.com/bakkdoor/grit.git
-cho45 git://github.com/cho45/grit.git
-defunkt git://github.com/defunkt/grit.git
-koke git://github.com/koke/grit.git
-origin git@github.com:mojombo/grit.git</code></pre>
-
-<p>This means we can pull contributions from any of these users pretty easily. But notice that only the origin remote is an SSH URL, so it’s the only one I can push to (we’ll cover why this is in Chapter 4).</p>
-
-<h3 id='adding_remote_repositories'>Adding Remote Repositories</h3>
-
-<p>I’ve mentioned and given some demonstrations of adding remote repositories in previous sections, but here is how to do it explicitly. To add a new remote Git repository as a shortname you can reference easily, run <code>git remote add [shortname] [url]</code>:</p>
-
-<pre><code>$ git remote
-origin
-$ git remote add pb git://github.com/paulboone/ticgit.git
-$ git remote -v
-origin git://github.com/schacon/ticgit.git
-pb git://github.com/paulboone/ticgit.git</code></pre>
-
-<p>Now you can use the string pb on the command line in lieu of the whole URL. For example, if you want to fetch all the information that Paul has but that you don’t yet have in your repository, you can run git fetch pb:</p>
-
-<pre><code>$ git fetch pb
-remote: Counting objects: 58, done.
-remote: Compressing objects: 100% (41/41), done.
-remote: Total 44 (delta 24), reused 1 (delta 0)
-Unpacking objects: 100% (44/44), done.
-From git://github.com/paulboone/ticgit
- * [new branch] master -&gt; pb/master
- * [new branch] ticgit -&gt; pb/ticgit</code></pre>
-
-<p>Paul’s master branch is accessible locally as <code>pb/master</code> — you can merge it into one of your branches, or you can check out a local branch at that point if you want to inspect it.</p>
-
-<h3 id='fetching_and_pulling_from_your_remotes'>Fetching and Pulling from Your Remotes</h3>
-
-<p>As you just saw, to get data from your remote projects, you can run:</p>
-
-<pre><code>$ git fetch [remote-name]</code></pre>
-
-<p>The command goes out to that remote project and pulls down all the data from that remote project that you don’t have yet. After you do this, you should have references to all the branches from that remote, which you can merge in or inspect at any time. (We’ll go over what branches are and how to use them in much more detail in Chapter 3.)</p>
-
-<p>If you clone a repository, the command automatically adds that remote repository under the name origin. So, <code>git fetch origin</code> fetches any new work that has been pushed to that server since you cloned (or last fetched from) it. It’s important to note that the fetch command pulls the data to your local repository — it doesn’t automatically merge it with any of your work or modify what you’re currently working on. You have to merge it manually into your work when you’re ready.</p>
-
-<p>If you have a branch set up to track a remote branch (see the next section and Chapter 3 for more information), you can use the <code>git pull</code> command to automatically fetch and then merge a remote branch into your current branch. This may be an easier or more comfortable workflow for you; and by default, the <code>git clone</code> command automatically sets up your local master branch to track the remote master branch on the server you cloned from (assuming the remote has a master branch). Running <code>git pull</code> generally fetches data from the server you originally cloned from and automatically tries to merge it into the code you’re currently working on.</p>
-
-<h3 id='pushing_to_your_remotes'>Pushing to Your Remotes</h3>
-
-<p>When you have your project at a point that you want to share, you have to push it upstream. The command for this is simple: <code>git push [remote-name] [branch-name]</code>. If you want to push your master branch to your <code>origin</code> server (again, cloning generally sets up both of those names for you automatically), then you can run this to push your work back up to the server:</p>
-
-<pre><code>$ git push origin master</code></pre>
-
-<p>This command works only if you cloned from a server to which you have write access and if nobody has pushed in the meantime. If you and someone else clone at the same time and they push upstream and then you push upstream, your push will rightly be rejected. You’ll have to pull down their work first and incorporate it into yours before you’ll be allowed to push. See Chapter 3 for more detailed information on how to push to remote servers.</p>
-
-<h3 id='inspecting_a_remote'>Inspecting a Remote</h3>
-
-<p>If you want to see more information about a particular remote, you can use the <code>git remote show [remote-name]</code> command. If you run this command with a particular shortname, such as <code>origin</code>, you get something like this:</p>
-
-<pre><code>$ git remote show origin
-* remote origin
- URL: git://github.com/schacon/ticgit.git
- Remote branch merged with &#39;git pull&#39; while on branch master
- master
- Tracked remote branches
- master
- ticgit</code></pre>
-
-<p>It lists the URL for the remote repository as well as the tracking branch information. The command helpfully tells you that if you’re on the master branch and you run <code>git pull</code>, it will automatically merge in the master branch on the remote after it fetches all the remote references. It also lists all the remote references it has pulled down.</p>
-
-<p>That is a simple example you’re likely to encounter. When you’re using Git more heavily, however, you may see much more information from <code>git remote show</code>:</p>
-
-<pre><code>$ git remote show origin
-* remote origin
- URL: git@github.com:defunkt/github.git
- Remote branch merged with &#39;git pull&#39; while on branch issues
- issues
- Remote branch merged with &#39;git pull&#39; while on branch master
- master
- New remote branches (next fetch will store in remotes/origin)
- caching
- Stale tracking branches (use &#39;git remote prune&#39;)
- libwalker
- walker2
- Tracked remote branches
- acl
- apiv2
- dashboard2
- issues
- master
- postgres
- Local branch pushed with &#39;git push&#39;
- master:master</code></pre>
-
-<p>This command shows which branch is automatically pushed when you run <code>git push</code> on certain branches. It also shows you which remote branches on the server you don’t yet have, which remote branches you have that have been removed from the server, and multiple branches that are automatically merged when you run <code>git pull</code>.</p>
-
-<h3 id='removing_and_renaming_remotes'>Removing and Renaming Remotes</h3>
-
-<p>If you want to rename a reference, in newer versions of Git you can run <code>git remote rename</code> to change a remote’s shortname. For instance, if you want to rename <code>pb</code> to <code>paul</code>, you can do so with <code>git remote rename</code>:</p>
-
-<pre><code>$ git remote rename pb paul
-$ git remote
-origin
-paul</code></pre>
-
-<p>It’s worth mentioning that this changes your remote branch names, too. What used to be referenced at <code>pb/master</code> is now at <code>paul/master</code>.</p>
-
-<p>If you want to remove a reference for some reason — you’ve moved the server or are no longer using a particular mirror, or perhaps a contributor isn’t contributing anymore — you can use <code>git remote rm</code>:</p>
-
-<pre><code>$ git remote rm paul
-$ git remote
-origin</code></pre>
+<pre><code>$ git log --pretty=format:&quot;%h %s&quot; --graph
+* 2d3acf9 ignore errors from SIGCHLD on trap
+* 5e3ee11 Merge branch &#39;master&#39; of git://github.com/dustin/grit
+|\
+| * 420eac9 Added a method for getting the current branch.
+* | 30e367c timeout code and tests
+* | 5a09431 add timeout protection to grit
+* | e1193f8 support for heads with slashes in them
+|/
+* d6016bc require time for xmlschema
+* 11d191e Merge branch &#39;defunkt&#39; into local</code></pre>
+<p>Those are only some simple output-formatting options to <code>git log</code> — there are many more. Table 2-2 lists the options we’ve covered so far and some other common formatting options that may be useful, along with how they change the output of the log command.</p>
+<hr />
<div id='nav'>
<a href='ch2-4.html'>prev</a> | <a href='ch2-6.html'>next</a>
</div>
View
211 book/ch2-6.html
@@ -1,212 +1,47 @@
---
layout: master
-title: Pro Git 2.6 Git Basics Tagging
+title: Pro Git 2.6 Git Basics Option Description
---
-<h2 id='tagging'>Tagging</h2>
+<h2 id='option_description'>Option Description</h2>
-<p>Like most VCSs, Git has the ability to tag specific points in history as being important. Generally, people use this functionality to mark release points (v1.0, and so on). In this section, you’ll learn how to list the available tags, how to create new tags, and what the different types of tags are.</p>
+<p><code>-p</code> Show the patch introduced with each commit.</p>
-<h3 id='listing_your_tags'>Listing Your Tags</h3>
+<p><code>--stat</code> Show statistics for files modified in each commit.</p>
-<p>Listing the available tags in Git is straightforward. Just type <code>git tag</code>:</p>
+<p><code>--shortstat</code> Display only the changed/insertions/deletions line from the <code>--stat</code> command.</p>
-<pre><code>$ git tag
-v0.1
-v1.3</code></pre>
+<p><code>--name-only</code> Show the list of files modified after the commit information.</p>
-<p>This command lists the tags in alphabetical order; the order in which they appear has no real importance.</p>
+<p><code>--name-status</code> Show the list of files affected with added/modified/deleted information as well.</p>
-<p>You can also search for tags with a particular pattern. The Git source repo, for instance, contains more than 240 tags. If you’re only interested in looking at the 1.4.2 series, you can run this:</p>
+<p><code>--abbrev-commit</code> Show only the first few characters of the SHA-1 checksum instead of all 40.</p>
-<pre><code>$ git tag -l &#39;v1.4.2.*&#39;
-v1.4.2.1
-v1.4.2.2
-v1.4.2.3
-v1.4.2.4</code></pre>
+<p><code>--relative-date</code> Display the date in a relative format (for example, “2 weeks ago”) instead of using the full date format.</p>
-<h3 id='creating_tags'>Creating Tags</h3>
+<p><code>--graph</code> Display an ASCII graph of the branch and merge history beside the log output.</p>
-<p>Git uses two main types of tags: lightweight and annotated. A lightweight tag is very much like a branch that doesn’t change — it’s just a pointer to a specific commit. Annotated tags, however, are stored as full objects in the Git database. They’re checksummed; contain the tagger name, e-mail, and date; have a tagging message; and can be signed and verified with GNU Privacy Guard (GPG). It’s generally recommended that you create annotated tags so you can have all this information; but if you want a temporary tag or for some reason don’t want to keep the other information, lightweight tags are available too.</p>
+<p><code>--pretty</code> Show commits in an alternate format. Options include oneline, short, full, fuller, and format (where you specify</p>
-<h3 id='annotated_tags'>Annotated Tags</h3>
+<pre><code> your own format).</code></pre>
+<hr />
+<p>Table: Some <code>git log</code> options</p>
-<p>Creating an annotated tag in Git is simple. The easiest way is to specify <code>-a</code> when you run the <code>tag</code> command:</p>
+<h3 id='limiting_log_output'>Limiting Log Output</h3>
-<pre><code>$ git tag -a v1.4 -m &#39;my version 1.4&#39;
-$ git tag
-v0.1
-v1.3
-v1.4</code></pre>
+<p>In addition to output-formatting options, git log takes a number of useful limiting options — that is, options that let you show only a subset of commits. You’ve seen one such option already — the <code>-2</code> option, which show only the last two commits. In fact, you can do <code>-&lt;n&gt;</code>, where <code>n</code> is any integer to show the last <code>n</code> commits. In reality, you’re unlikely to use that often, because Git by default pipes all output through a pager so you see only one page of log output at a time.</p>
-<p>The <code>-m</code> specifies a tagging message, which is stored with the tag. If you don’t specify a message for an annotated tag, Git launches your editor so you can type it in.</p>
+<p>However, the time-limiting options such as <code>--since</code> and <code>--until</code> are very useful. For example, this command gets the list of commits made in the last two weeks:</p>
-<p>You can see the tag data along with the commit that was tagged by using the <code>git show</code> command:</p>
+<pre><code>$ git log --since=2.weeks</code></pre>
-<pre><code>$ git show v1.4
-tag v1.4
-Tagger: Scott Chacon &lt;schacon@gee-mail.com&gt;
-Date: Mon Feb 9 14:45:11 2009 -0800
+<p>This command works with lots of formats — you can specify a specific date (“2008-01-15”) or a relative date such as “2 years 1 day 3 minutes ago”.</p>
-my version 1.4
-commit 15027957951b64cf874c3557a0f3547bd83b3ff6
-Merge: 4a447f7... a6b4c97...
-Author: Scott Chacon &lt;schacon@gee-mail.com&gt;
-Date: Sun Feb 8 19:02:46 2009 -0800
+<p>You can also filter the list to commits that match some search criteria. The <code>--author</code> option allows you to filter on a specific author, and the <code>--grep</code> option lets you search for keywords in the commit messages. (Note that if you want to specify both author and grep options, you have to add <code>--all-match</code> or the command will match commits with either.)</p>
- Merge branch &#39;experiment&#39;</code></pre>
-
-<p>That shows the tagger information, the date the commit was tagged, and the annotation message before showing the commit information.</p>
-
-<h3 id='signed_tags'>Signed Tags</h3>
-
-<p>You can also sign your tags with GPG, assuming you have a private key. All you have to do is use <code>-s</code> instead of <code>-a</code>:</p>
-
-<pre><code>$ git tag -s v1.5 -m &#39;my signed 1.5 tag&#39;
-You need a passphrase to unlock the secret key for
-user: &quot;Scott Chacon &lt;schacon@gee-mail.com&gt;&quot;
-1024-bit DSA key, ID F721C45A, created 2009-02-09</code></pre>
-
-<p>If you run <code>git show</code> on that tag, you can see your GPG signature attached to it:</p>
-
-<pre><code>$ git show v1.5
-tag v1.5
-Tagger: Scott Chacon &lt;schacon@gee-mail.com&gt;
-Date: Mon Feb 9 15:22:20 2009 -0800
-
-my signed 1.5 tag
------BEGIN PGP SIGNATURE-----
-Version: GnuPG v1.4.8 (Darwin)
-
-iEYEABECAAYFAkmQurIACgkQON3DxfchxFr5cACeIMN+ZxLKggJQf0QYiQBwgySN
-Ki0An2JeAVUCAiJ7Ox6ZEtK+NvZAj82/
-=WryJ
------END PGP SIGNATURE-----
-commit 15027957951b64cf874c3557a0f3547bd83b3ff6
-Merge: 4a447f7... a6b4c97...
-Author: Scott Chacon &lt;schacon@gee-mail.com&gt;
-Date: Sun Feb 8 19:02:46 2009 -0800
-
- Merge branch &#39;experiment&#39;</code></pre>
-
-<p>A bit later, you’ll learn how to verify signed tags.</p>
-
-<h3 id='lightweight_tags'>Lightweight Tags</h3>
-
-<p>Another way to tag commits is with a lightweight tag. This is basically the commit checksum stored in a file — no other information is kept. To create a lightweight tag, don’t supply the <code>-a</code>, <code>-s</code>, or <code>-m</code> option:</p>
-
-<pre><code>$ git tag v1.4-lw
-$ git tag
-v0.1
-v1.3
-v1.4
-v1.4-lw
-v1.5</code></pre>
-
-<p>This time, if you run <code>git show</code> on the tag, you don’t see the extra tag information. The command just shows the commit:</p>
-
-<pre><code>$ git show v1.4-lw
-commit 15027957951b64cf874c3557a0f3547bd83b3ff6
-Merge: 4a447f7... a6b4c97...
-Author: Scott Chacon &lt;schacon@gee-mail.com&gt;
-Date: Sun Feb 8 19:02:46 2009 -0800
-
- Merge branch &#39;experiment&#39;</code></pre>
-
-<h3 id='verifying_tags'>Verifying Tags</h3>
-
-<p>To verify a signed tag, you use <code>git tag -v [tag-name]</code>. This command uses GPG to verify the signature. You need the signer’s public key in your keyring for this to work properly:</p>
-
-<pre><code>$ git tag -v v1.4.2.1
-object 883653babd8ee7ea23e6a5c392bb739348b1eb61
-type commit
-tag v1.4.2.1
-tagger Junio C Hamano &lt;junkio@cox.net&gt; 1158138501 -0700
-
-GIT 1.4.2.1
-
-Minor fixes since 1.4.2, including git-mv and git-http with alternates.
-gpg: Signature made Wed Sep 13 02:08:25 2006 PDT using DSA key ID F3119B9A
-gpg: Good signature from &quot;Junio C Hamano &lt;junkio@cox.net&gt;&quot;
-gpg: aka &quot;[jpeg image of size 1513]&quot;
-Primary key fingerprint: 3565 2A26 2040 E066 C9A7 4A7D C0C6 D9A4 F311 9B9A</code></pre>
-
-<p>If you don’t have the signer’s public key, you get something like this instead:</p>
-
-<pre><code>gpg: Signature made Wed Sep 13 02:08:25 2006 PDT using DSA key ID F3119B9A
-gpg: Can&#39;t check signature: public key not found
-error: could not verify the tag &#39;v1.4.2.1&#39;</code></pre>
-
-<h3 id='tagging_later'>Tagging Later</h3>
-
-<p>You can also tag commits after you’ve moved past them. Suppose your commit history looks like this:</p>
-
-<pre><code>$ git log --pretty=oneline
-15027957951b64cf874c3557a0f3547bd83b3ff6 Merge branch &#39;experiment&#39;
-a6b4c97498bd301d84096da251c98a07c7723e65 beginning write support
-0d52aaab4479697da7686c15f77a3d64d9165190 one more thing
-6d52a271eda8725415634dd79daabbc4d9b6008e Merge branch &#39;experiment&#39;
-0b7434d86859cc7b8c3d5e1dddfed66ff742fcbc added a commit function
-4682c3261057305bdd616e23b64b0857d832627b added a todo file
-166ae0c4d3f420721acbb115cc33848dfcc2121a started write support
-9fceb02d0ae598e95dc970b74767f19372d61af8 updated rakefile
-964f16d36dfccde844893cac5b347e7b3d44abbc commit the todo
-8a5cbc430f1a9c3d00faaeffd07798508422908a updated readme</code></pre>
-
-<p>Now, suppose you forgot to tag the project at v1.2, which was at the &#8220;updated rakefile&#8221; commit. You can add it after the fact. To tag that commit, you specify the commit checksum (or part of it) at the end of the command:</p>
-
-<pre><code>$ git tag -a v1.2 9fceb02</code></pre>
-
-<p>You can see that you’ve tagged the commit:</p>
-
-<pre><code>$ git tag
-v0.1
-v1.2
-v1.3
-v1.4
-v1.4-lw
-v1.5
-
-$ git show v1.2
-tag v1.2
-Tagger: Scott Chacon &lt;schacon@gee-mail.com&gt;
-Date: Mon Feb 9 15:32:16 2009 -0800
-
-version 1.2
-commit 9fceb02d0ae598e95dc970b74767f19372d61af8
-Author: Magnus Chacon &lt;mchacon@gee-mail.com&gt;
-Date: Sun Apr 27 20:43:35 2008 -0700
-
- updated rakefile
-...</code></pre>
-
-<h3 id='sharing_tags'>Sharing Tags</h3>
-
-<p>By default, the <code>git push</code> command doesn’t transfer tags to remote servers. You will have to explicitly push tags to a shared server after you have created them. This process is just like sharing remote branches — you can run <code>git push origin [tagname]</code>.</p>
-
-<pre><code>$ git push origin v1.5
-Counting objects: 50, done.
-Compressing objects: 100% (38/38), done.
-Writing objects: 100% (44/44), 4.56 KiB, done.
-Total 44 (delta 18), reused 8 (delta 1)
-To git@github.com:schacon/simplegit.git
-* [new tag] v1.5 -&gt; v1.5</code></pre>
-
-<p>If you have a lot of tags that you want to push up at once, you can also use the <code>--tags</code> option to the <code>git push</code> command. This will transfer all of your tags to the remote server that are not already there.</p>
-
-<pre><code>$ git push origin --tags
-Counting objects: 50, done.
-Compressing objects: 100% (38/38), done.
-Writing objects: 100% (44/44), 4.56 KiB, done.
-Total 44 (delta 18), reused 8 (delta 1)
-To git@github.com:schacon/simplegit.git
- * [new tag] v0.1 -&gt; v0.1
- * [new tag] v1.2 -&gt; v1.2
- * [new tag] v1.4 -&gt; v1.4
- * [new tag] v1.4-lw -&gt; v1.4-lw
- * [new tag] v1.5 -&gt; v1.5</code></pre>
-
-<p>Now, when someone else clones or pulls from your repository, they will get all your tags as well.</p>
+<p>The last really useful option to pass to <code>git log</code> as a filter is a path. If you specify a directory or file name, you can limit the log output to commits that introduced a change to those files. This is always the last option and is generally preceded by double dashes (<code>--</code>) to separate the paths from the options.</p>
+<p>In Table 2-3 we’ll list these and a few other common options for your reference.</p>
+<hr />
<div id='nav'>
<a href='ch2-5.html'>prev</a> | <a href='ch2-7.html'>next</a>
</div>
View
78 book/ch2-7.html
@@ -1,73 +1,43 @@
---
layout: master
-title: Pro Git 2.7 Git Basics Tips and Tricks
+title: Pro Git 2.7 Git Basics Option Description
---
-<h2 id='tips_and_tricks'>Tips and Tricks</h2>
+<h2 id='option_description'>Option Description</h2>
-<p>Before we finish this chapter on basic Git, a few little tips and tricks may make your Git experience a bit simpler, easier, or more familiar. Many people use Git without using any of these tips, and we won’t refer to them or assume you’ve used them later in the book; but you should probably know how to do them.</p>
+<p><code>-(n)</code> Show only the last n commits</p>
-<h3 id='autocompletion'>Auto-Completion</h3>
+<p><code>--since</code>, <code>--after</code> Limit the commits to those made after the specified date.</p>
-<p>If you use the Bash shell, Git comes with a nice auto-completion script you can enable. Download the Git source code, and look in the <code>contrib/completion</code> directory; there should be a file called <code>git-completion.bash</code>. Copy this file to your home directory, and add this to your <code>.bashrc</code> file:</p>
+<p><code>--until</code>, <code>--before</code> Limit the commits to those made before the specified date.</p>
-<pre><code>source ~/.git-completion.bash</code></pre>
+<p><code>--author</code> Only show commits in which the author entry matches the specified string.</p>
-<p>If you want to set up Git to automatically have Bash shell completion for all users, copy this script to the <code>/opt/local/etc/bash_completion.d</code> directory on Mac systems or to the <code>/etc/bash_completion.d/</code> directory on Linux systems. This is a directory of scripts that Bash will automatically load to provide shell completions.</p>
+<p><code>--committer</code> Only show commits in which the committer entry matches</p>
-<p>If you’re using Windows with Git Bash, which is the default when installing Git on Windows with msysGit, auto-completion should be preconfigured.</p>
+<pre><code> the specified string.</code></pre>
+<hr />
+<p>Table: Some <code>git log</code> filter options</p>
-<p>Press the Tab key when you’re writing a Git command, and it should return a set of suggestions for you to pick from:</p>
+<p>For example, if you want to see which commits modifying test files in the Git source code history were committed by Junio Hamano and were not merges in the month of October 2008, you can run something like this:</p>
-<pre><code>$ git co&lt;tab&gt;&lt;tab&gt;
-commit config</code></pre>
+<pre><code>$ git log --pretty=&quot;%h - %s&quot; --author=gitster --since=&quot;2008-10-01&quot; \
+ --before=&quot;2008-11-01&quot; --no-merges -- t/
+5610e3b - Fix testcase failure when extended attribute
+acd3b9e - Enhance hold_lock_file_for_{update,append}()
+f563754 - demonstrate breakage of detached checkout wi
+d1a43f2 - reset --hard/read-tree --reset -u: remove un
+51a94af - Fix &quot;checkout --track -b newbranch&quot; on detac
+b0ad11e - pull: allow &quot;git pull origin $something:$cur</code></pre>
-<p>In this case, typing git co and then pressing the Tab key twice suggests commit and config. Adding <code>m&lt;tab&gt;</code> completes <code>git commit</code> automatically.</p>
+<p>Of the nearly 20,000 commits in the Git source code history, this command shows the 6 that match those criteria.</p>
-<p>This also works with options, which is probably more useful. For instance, if you’re running a <code>git log</code> command and can’t remember one of the options, you can start typing it and press Tab to see what matches:</p>
+<h3 id='using_a_gui_to_visualize_history'>Using a GUI to Visualize History</h3>
-<pre><code>$ git log --s&lt;tab&gt;
---shortstat --since= --src-prefix= --stat --summary</code></pre>
+<p>If you like to use a more graphical tool to visualize your commit history, you may want to take a look at a Tcl/Tk program called gitk that is distributed with Git. Gitk is basically a visual <code>git log</code> tool, and it accepts nearly all the filtering options that <code>git log</code> does. If you type gitk on the command line in your project, you should see something like Figure 2-2.</p>
-<p>That’s a pretty nice trick and may save you some time and documentation reading.</p>
+<p><center><img src="/figures/ch2/18333fig0202-tn.png"></center><br/> Figure 2-2. The gitk history visualizer.</p>
-<h3 id='git_aliases'>Git Aliases</h3>
-
-<p>Git doesn’t infer your command if you type it in partially. If you don’t want to type the entire text of each of the Git commands, you can easily set up an alias for each command using <code>git config</code>. Here are a couple of examples you may want to set up:</p>
-
-<pre><code>$ git config --global alias.co checkout
-$ git config --global alias.br branch
-$ git config --global alias.ci commit
-$ git config --global alias.st status</code></pre>
-
-<p>This means that, for example, instead of typing <code>git commit</code>, you just need to type <code>git ci</code>. As you go on using Git, you’ll probably use other commands frequently as well; in this case, don’t hesitate to create new aliases.</p>
-
-<p>This technique can also be very useful in creating commands that you think should exist. For example, to correct the usability problem you encountered with unstaging a file, you can add your own unstage alias to Git:</p>
-
-<pre><code>$ git config --global alias.unstage &#39;reset HEAD --&#39;</code></pre>
-
-<p>This makes the following two commands equivalent:</p>
-
-<pre><code>$ git unstage fileA
-$ git reset HEAD fileA</code></pre>
-
-<p>This seems a bit clearer. It’s also common to add a <code>last</code> command, like this:</p>
-
-<pre><code>$ git config --global alias.last &#39;log -1 HEAD&#39;</code></pre>
-
-<p>This way, you can see the last commit easily:</p>
-
-<pre><code>$ git last
-commit 66938dae3329c7aebe598c2246a8e6af90d04646
-Author: Josh Goebel &lt;dreamer3@example.com&gt;
-Date: Tue Aug 26 19:48:51 2008 +0800
-
- test for current head
-
- Signed-off-by: Scott Chacon &lt;schacon@example.com&gt;</code></pre>
-
-<p>As you can tell, Git simply replaces the new command with whatever you alias it for. However, maybe you want to run an external command, rather than a Git subcommand. In that case, you start the command with a <code>!</code> character. This is useful if you write your own tools that work with a Git repository. We can demonstrate by aliasing <code>git visual</code> to run <code>gitk</code>:</p>
-
-<pre><code>$ git config --global alias.visual &quot;!gitk&quot;</code></pre>
+<p>You can see the commit history in the top half of the window along with a nice ancestry graph. The diff viewer in the bottom half of the window shows you the changes introduced at any commit you click.</p>
<div id='nav'>
<a href='ch2-6.html'>prev</a> | <a href='ch2-8.html'>next</a>
View
88 book/ch2-8.html
@@ -1,9 +1,89 @@
---
layout: master
-title: Pro Git 2.8 Git Basics Summary
+title: Pro Git 2.8 Git Basics Undoing Things
---
-<h2 id='summary'>Summary</h2>
+<h2 id='undoing_things'>Undoing Things</h2>
-<p>At this point, you can do all the basic local Git operations — creating or cloning a repository, making changes, staging and committing those changes, and viewing the history of all the changes the repository has been through. Next, we’ll cover Git’s killer feature: its branching model.</p><div id='nav'>
-<a href='ch2-7.html'>prev</a> | <a href='ch3-0.html'>next</a>
+<p>At any stage, you may want to undo something. Here, we’ll review a few basic tools for undoing changes that you’ve made. Be careful, because you can’t always undo some of these undos. This is one of the few areas in Git where you may lose some work if you do it wrong.</p>
+
+<h3 id='changing_your_last_commit'>Changing Your Last Commit</h3>
+
+<p>One of the common undos takes place when you commit too early and possibly forget to add some files, or you mess up your commit message. If you want to try that commit again, you can run commit with the <code>--amend</code> option:</p>
+
+<pre><code>$ git commit --amend</code></pre>
+
+<p>This command takes your staging area and uses it for the commit. If you’ve have made no changes since your last commit (for instance, you run this command immediately after your previous commit), then your snapshot will look exactly the same and all you’ll change is your commit message.</p>
+
+<p>The same commit-message editor fires up, but it already contains the message of your previous commit. You can edit the message the same as always, but it overwrites your previous commit.</p>
+
+<p>As an example, if you commit and then realize you forgot to stage the changes in a file you wanted to add to this commit, you can do something like this:</p>
+
+<pre><code>$ git commit -m &#39;initial commit&#39;
+$ git add forgotten_file
+$ git commit --amend</code></pre>
+
+<p>All three of these commands end up with a single commit — the second commit replaces the results of the first.</p>
+
+<h3 id='unstaging_a_staged_file'>Unstaging a Staged File</h3>
+
+<p>The next two sections demonstrate how to wrangle your staging area and working directory changes. The nice part is that the command you use to determine the state of those two areas also reminds you how to undo changes to them. For example, let’s say you’ve changed two files and want to commit them as two separate changes, but you accidentally type <code>git add *</code> and stage them both. How can you unstage one of the two? The <code>git status</code> command reminds you:</p>
+
+<pre><code>$ git add .
+$ git status
+# On branch master
+# Changes to be committed:
+# (use &quot;git reset HEAD &lt;file&gt;...&quot; to unstage)
+#
+# modified: README.txt
+# modified: benchmarks.rb
+#</code></pre>
+
+<p>Right below the “Changes to be committed” text, it says use <code>git reset HEAD &lt;file&gt;...</code> to unstage. So, let’s use that advice to unstage the benchmarks.rb file:</p>
+
+<pre><code>$ git reset HEAD benchmarks.rb
+benchmarks.rb: locally modified
+$ git status
+# On branch master
+# Changes to be committed:
+# (use &quot;git reset HEAD &lt;file&gt;...&quot; to unstage)
+#
+# modified: README.txt
+#
+# Changed but not updated:
+# (use &quot;git add &lt;file&gt;...&quot; to update what will be committed)
+# (use &quot;git checkout -- &lt;file&gt;...&quot; to discard changes in working directory)
+#
+# modified: benchmarks.rb
+#</code></pre>
+
+<p>The command is a bit strange, but it works. The benchmarks.rb file is modified but once again unstaged.</p>
+
+<h3 id='unmodifying_a_modified_file'>Unmodifying a Modified File</h3>
+
+<p>What if you realize that you don’t want to keep your changes to the benchmarks.rb file? How can you easily unmodify it — revert it back to what it looked like when you last committed (or initially cloned, or however you got it into your working directory)? Luckily, <code>git status</code> tells you how to do that, too. In the last example output, the unstaged area looks like this:</p>
+
+<pre><code># Changed but not updated:
+# (use &quot;git add &lt;file&gt;...&quot; to update what will be committed)
+# (use &quot;git checkout -- &lt;file&gt;...&quot; to discard changes in working directory)
+#
+# modified: benchmarks.rb
+#</code></pre>
+
+<p>It tells you pretty explicitly how to discard the changes you’ve made (at least, the newer versions of Git, 1.6.1 and later, do this — if you have an older version, we highly recommend upgrading it to get some of these nicer usability features). Let’s do what it says:</p>
+
+<pre><code>$ git checkout -- benchmarks.rb
+$ git status
+# On branch master
+# Changes to be committed:
+# (use &quot;git reset HEAD &lt;file&gt;...&quot; to unstage)
+#
+# modified: README.txt
+#</code></pre>
+
+<p>You can see that the changes have been reverted. You should also realize that this is a dangerous command: any changes you made to that file are gone — you just copied another file over it. Don’t ever use this command unless you absolutely know that you don’t want the file. If you just need to get it out of the way, we’ll go over stashing and branching in the next chapter; these are generally better ways to go.</p>
+
+<p>Remember, anything that is committed in Git can almost always be recovered. Even commits that were on branches that were deleted or commits that were overwritten with an <code>--amend</code> commit can be recovered (see Chapter 9 for data recovery). However, anything you lose that was never committed is likely never to be seen again.</p>
+
+<div id='nav'>
+<a href='ch2-7.html'>prev</a> | <a href='ch2-9.html'>next</a>
</div>
View
2 book/ch3-0.html
@@ -9,5 +9,5 @@
<p>Some people refer to the branching model in Git as its “killer feature,” and it certainly sets Git apart in the VCS community. Why is it so special? The way Git branches is incredibly lightweight, making branching operations nearly instantaneous and switching back and forth between branches generally just as fast. Unlike many other VCSs, Git encourages a workflow that branches and merges often, even multiple times in a day. Understanding and mastering this feature gives you a powerful and unique tool and can literally change the way that you develop.</p>
<div id='nav'>
-<a href='ch2-8.html'>prev</a> | <a href='ch3-1.html'>next</a>
+<a href='ch2-12.html'>prev</a> | <a href='ch3-1.html'>next</a>
</div>
View
4 book/es/ch3-0.html
@@ -4,12 +4,10 @@
---
<h1>Chapter 3</h1><h1 id='ramificaciones_en_git'>Ramificaciones en Git</h1>
-<p>Cualquier sistema de control de versiones moderno tiene algún mecanismo para soportar distintas ramas. Cuando hablamos de ramificaciones, significa que tu has tomado la rama principal de desarrollo (master) y a partir de ahí has continuado trabajando sin seguir la rama principal de desarrollo. En muchas sistemas de control de versiones este proceso es costoso, pues a menudo requiere crear una nueva copia del código, lo cual puede tomar mucho tiempo cuando se trata de proyectos grandes.</p>
+<p>Cualquier sistema de control de versiones moderno tiene algún mecanismo para soportar distintos ramales. Cuando hablamos de ramificaciones, significa que tu has tomado la rama principal de desarrollo (master) y a partir de ahí has continuado trabajando sin seguir la rama principal de desarrollo. En muchas sistemas de control de versiones este proceso es costoso, pues a menudo requiere crear una nueva copia del código, lo cual puede tomar mucho tiempo cuando se trata de proyectos grandes.</p>
<p>Algunas personas resaltan que uno de los puntos mas fuertes de Git es su sistema de ramificaciones y lo cierto es que esto le hace resaltar sobre los otros sistemas de control de versiones. ¿Porqué esto es tan importante? La forma en la que Git maneja las ramificaciones es increíblemente rápida, haciendo así de las operaciones de ramificación algo casi instantáneo, al igual que el avance o el retroceso entre distintas ramas, lo cual también es tremendamente rápido. A diferencia de otros sistemas de control de versiones, Git promueve un ciclo de desarrollo donde las ramas se crean y se unen ramas entre sí, incluso varias veces en el mismo día. Entender y manejar esta opción te proporciona una poderosa y exclusiva herramienta que puede, literalmente, cambiar la forma en la que desarrollas.</p>
-<p>Git no modela ni almacena sus datos de este modo. En cambio, Git modela sus datos más como un conjunto de instantáneas de un mini sistema de archivos. Cada vez que confirmas un cambio, o</p>
-
<div id='nav'>
<a href='ch2-8.html'>prev</a> | <a href='ch3-1.html'>next</a>
</div>
View
74 book/es/ch3-1.html
@@ -4,94 +4,82 @@
---
<h2 id='qu_es_una_rama'>¿Qué es una rama?</h2>
-<p>$ git add README test.rb LICENSE $ git commit -m &#8216;initial commit of my project&#8217;</p>
+<p>Para entender realmente cómo ramifica Git, previamente hemos de examinar la forma en que almacena sus datos. Recordando lo citado en el capítulo 1, Git no los almacena de forma incremental (guardando solo diferencias), sino que los almacena como una serie de instantáneas (copias puntuales de los archivos completos, tal y como se encuentran en ese momento).</p>
-<p>To really understand the way Git does branching, we need to take a step back and examine how Git stores its data. As you may remember from Chapter 1, Git doesn’t store data as a series of changesets or deltas, but instead as a series of snapshots.</p>
+<p>En cada confirmación de cambios (commit), Git almacena un punto de control que conserva: un apuntador a la copia puntual de los contenidos preparados (staged), unos metadatos con el autor y el mensaje explicativo, y uno o varios apuntadores a las confirmaciones (commit) que sean padres directos de esta (un padre en los casos de confirmación normal, y múltiples padres en los casos de estar confirmando una fusión (merge) de dos o mas ramas).</p>
-<p>When you commit in Git, Git stores a commit object that contains a pointer to the snapshot of the content you staged, the author and message metadata, and zero or more pointers to the commit or commits that were the direct parents of this commit: zero parents for the first commit, one parent for a normal commit, and multiple parents for a commit that results from a merge of two or more branches.</p>
-
-<p>To visualize this, let’s assume that you have a directory containing three files, and you stage them all and commit. Staging the files checksums each one (the SHA-1 hash we mentioned in Chapter 1), stores that version of the file in the Git repository (Git refers to them as blobs), and adds that checksum to the staging area:</p>
+<p>Para ilustrar esto, vamos a suponer, por ejemplo, que tienes una carpeta con tres archivos, que preparas (stage) todos ellos y los confirmas (commit). Al preparar los archivos, Git realiza una suma de control de cada uno de ellos (un resumen SHA-1, tal y como se mencionaba en el capítulo 1), almacena una copia de cada uno en el repositorio (estas copias se denominan &#8220;blobs&#8221;), y guarda cada suma de control en el área de preparación (staging area):</p>
<pre><code>$ git add README test.rb LICENSE
$ git commit -m &#39;initial commit of my project&#39;</code></pre>
-<p>Para entender realmente la manera que utiliza Git para realizar las ramificaciones, tenemos que dar una paso atrás y examinar como Git almacena los datos. Como recordarás, en el Capítulo 1, Git no almacena los datos como una lista de cambios en los archivos, en vez de eso utiliza un conjunto de instantáneas de un mini sistema de archivos.</p>
-
-<p>Cada vez que tu confirmas un cambio en Git, Git hace una foto del aspecto de todos tus archivos en ese momento, y guarda una referencia a esa instantánea, el autor y el mensaje con metadatos, además de cero o más referencias al cambio o cambios que son dependientes del último cambio realizado: cero dependencias para el primer cambio, una para When you commit in Git, Git stores a commit object that contains a pointer to the snapshot of the content you staged, the author and message metadata, and zero or more pointers to the commit or commits that were the direct parents of this commit: zero parents for the first commit, one parent for a normal commit, and multiple parents for a commit that results from a merge of two or more branches.</p>
-
-<p>When you create the commit by running <code>git commit</code>, Git checksums each subdirectory (in this case, just the root project directory) and stores those tree objects in the Git repository. Git then creates a commit object that has the metadata and a pointer to the root project tree so it can re-create that snapshot when needed.</p>
-
-<p>Para entender esto, asumamos que tu tienes un directorio que contiene tres archivos, entonces tu creas una instantánea de los cambios realizados en ellos y lo confirmas. Está instantánea de los tres archivos contiene los checksums de cada uno de ellos ( utilizando el hash SHA-1 que se mencionó en el Capítulo 1), guarda esa versión del archivo en el repositorio de Git ( Git hace referencia a ellos como blobs), y añade los checksums dejando así los archivos preparados.</p>
-
-<p>Cuando tu creas un cambio mediante el comando <code>git commit</code>, Git crea los checksums de cada directorio (en este caso solo el directorio raíz) y almacena estos como tres objetos en el repositorio de Git. Entonces Git crea los cambios para cada objeto, el cual tiene metainformación además de una referencia al directorio raíz, para así poder crear esa misma instantánea cuando sea necesario</p>
-
-<p>Tu repositorio de Git ahora contiene cinco objetos: un blob para el contenido de cada uno de tus tres archivos, un árbol que mantiene una lista de los contenidos de tu directorio y especifica cuales son los nombres de los archivos de cada blob, y un cambio que contiene una referencia de donde está el árbol y donde están los cambios</p>
+<p>Cuando creas una confirmación con el comando &#8216;git commit&#8217;, Git realiza sumas de control de cada subcarpeta (en el ejemplo, solamente tenemos la carpeta principal del proyecto), y guarda en el repositorio Git una copia de cada uno de los archivos contenidos en ella/s. Después, Git crea un objeto de confirmación con los metadatos pertinentes y un apuntador al nodo correspondiente del árbol de proyecto. Esto permitirá poder regenerar posteriormente dicha instantánea cuando sea necesario.</p>
-<p>Your Git repository now contains five objects: one blob for the contents of each of your three files, one tree that lists the contents of the directory and specifies which file names are stored as which blobs, and one commit with the pointer to that root tree and all the commit metadata. Conceptually, the data in your Git repository looks something like Figure 3-1.</p>
+<p>En este momento, el repositorio de Git contendrá cinco objetos: un &#8220;blob&#8221; para cada uno de los tres archivos, un árbol con la lista de contenidos de la carpeta (más sus respectivas relaciones con los &#8220;blobs&#8221;), y una confirmación de cambios (commit) apuntando a la raiz de ese árbol y conteniendo el resto de metadatos pertinentes. Conceptualmente, el contenido del repositorio Git será algo parecido a la Figura 3-1</p>
-<p><center><img src="/figures/ch3/18333fig0301-tn.png"></center><br/> Figure 3-1. Single commit repository data.</p>
+<p><center><img src="/figures/ch3/18333fig0301-tn.png"></center><br/> Figura 3-1. Datos en el repositorio tras una confirmación sencilla.</p>
-<p>If you make some changes and commit again, the next commit stores a pointer to the commit that came immediately before it. After two more commits, your history might look something like Figure 3-2.</p>
+<p>Si haces más cambios y vuelves a confirmar, la siguiente confirmación guardará un apuntador a esta su confirmación precedente. Tras un par de confirmaciones más, el registro ha de ser algo parecido a la Figura 3-2.</p>
-<p><center><img src="/figures/ch3/18333fig0302-tn.png"></center><br/> Figure 3-2. Git object data for multiple commits.</p>
+<p><center><img src="/figures/ch3/18333fig0302-tn.png"></center><br/> Figura 3-2. Datos en el repositorio tras una serie de confirmaciones.</p>
-<p>A branch in Git is simply a lightweight movable pointer to one of these commits. The default branch name in Git is master. As you initially make commits, you’re given a master branch that points to the last commit you made. Every time you commit, it moves forward automatically.</p>
+<p>Una rama Git es simplemente un apuntador móvil apuntando a una de esas confirmaciones. La rama por defecto de Git es la rama &#8216;master&#8217;. Con la primera confirmación de cambios que realicemos, se creará esta rama principal &#8216;master&#8217; apuntando a dicha confirmación. En cada confirmación de cambios que realicemos, la rama irá avanzando automáticamente. Y la rama &#8216;master&#8217; apuntará siempre a la última confirmación realizada.</p>
-<p><center><img src="/figures/ch3/18333fig0303-tn.png"></center><br/> Figure 3-3. Branch pointing into the commit data’s history.</p>
+<p><center><img src="/figures/ch3/18333fig0303-tn.png"></center><br/> Figura 3-3. Apuntadores en el registro de confirmaciones de una rama.</p>
-<p>What happens if you create a new branch? Well, doing so creates a new pointer for you to move around. Let’s say you create a new branch called testing. You do this with the <code>git branch</code> command:</p>
+<p>¿Qué sucede cuando creas una nueva rama? Bueno&#8230;.., simplemente se crea un nuevo apuntador para que lo puedas mover libremente. Por ejemplo, si quieres crear una nueva rama denominada &#8220;testing&#8221;. Usarás el comando &#8216;git branch&#8217;:</p>
<pre><code>$ git branch testing</code></pre>
-<p>This creates a new pointer at the same commit you’re currently on (see Figure 3-4).</p>
+<p>Esto creará un nuevo apuntador apuntando a la misma confirmación donde estés actualmente (ver Figura 3-4).</p>
-<p><center><img src="/figures/ch3/18333fig0304-tn.png"></center><br/> Figure 3-4. Multiple branches pointing into the commit’s data history.</p>
+<p><center><img src="/figures/ch3/18333fig0304-tn.png"></center><br/> Figura 3-4. Apuntadores de varias ramas en el registro de confirmaciones de cambio.</p>
-<p>How does Git know what branch you’re currently on? It keeps a special pointer called HEAD. Note that this is a lot different than the concept of HEAD in other VCSs you may be used to, such as Subversion or CVS. In Git, this is a pointer to the local branch you’re currently on. In this case, you’re still on master. The git branch command only created a new branch — it didn’t switch to that branch (see Figure 3-5).</p>
+<p>Y, ¿cómo sabe Git en qué rama estás en este momento? Pues&#8230;., mediante un apuntador especial denominado HEAD. Aunque es preciso comentar que este HEAD es totalmente distinto al concepto de HEAD en otros sistemas de control de cambios como Subversion o CVS. En Git, es simplemente el apuntador a la rama local en la que tú estés en ese momento. En este caso, en la rama &#8216;master&#8217;. Puesto que el comando git branch solamente crea una nueva rama, y no salta a dicha rama.</p>
-<p><center><img src="/figures/ch3/18333fig0305-tn.png"></center><br/> Figure 3-5. HEAD file pointing to the branch you’re on.</p>
+<p><center><img src="/figures/ch3/18333fig0305-tn.png"></center><br/> Figura 3-5. Apuntador HEAD a la rama donde estás actualmente.</p>
-<p>To switch to an existing branch, you run the <code>git checkout</code> command. Let’s switch to the new testing branch:</p>
+<p>Para saltar de una rama a otra, tienes que utilizar el comando &#8216;git checkout&#8217;. Hagamos una prueba, saltando a la rama &#8216;testing&#8217; recién creada:</p>
<pre><code>$ git checkout testing</code></pre>
-<p>This moves HEAD to point to the testing branch (see Figure 3-6).</p>
+<p>Esto mueve el apuntador HEAD a la rama &#8216;testing&#8217; (ver Figura 3-6).</p>
-<p><center><img src="/figures/ch3/18333fig0306-tn.png"></center><br/> Figure 3-6. HEAD points to another branch when you switch branches.</p>
+<p><center><img src="/figures/ch3/18333fig0306-tn.png"></center><br/> Figura 3-6. Apuntador HEAD apuntando a otra rama cuando saltamos de rama.</p>
-<p>What is the significance of that? Well, let’s do another commit:</p>
+<p>¿Cuál es el significado de todo esto?. Bueno&#8230;. lo veremos tras realizar otra confirmación de cambios:</p>
<pre><code>$ vim test.rb
$ git commit -a -m &#39;made a change&#39;</code></pre>
-<p>Figure 3-7 illustrates the result.</p>
+<p>La Figura 3-7 ilustra el resultado.</p>
-<p><center><img src="/figures/ch3/18333fig0307-tn.png"></center><br/> Figure 3-7. The branch that HEAD points to moves forward with each commit.</p>
+<p><center><img src="/figures/ch3/18333fig0307-tn.png"></center><br/> Figura 3-7. La rama apuntada por HEAD avanza con cada confirmación de cambios.</p>
-<p>This is interesting, because now your testing branch has moved forward, but your master branch still points to the commit you were on when you ran <code>git checkout</code> to switch branches. Let’s switch back to the master branch:</p>
+<p>Observamos algo interesante: la rama &#8216;testing&#8217; avanza, mientras que la rama &#8216;master&#8217; permanece en la confirmación donde estaba cuando lanzaste el comando &#8216;git checkout&#8217; para saltar. Volvamos ahora a la rama &#8216;master&#8217;:</p>
<pre><code>$ git checkout master</code></pre>
-<p>Figure 3-8 shows the result.</p>
+<p>La Figura 3-8 muestra el resultado.</p>
-<p><center><img src="/figures/ch3/18333fig0308-tn.png"></center><br/> Figure 3-8. HEAD moves to another branch on a checkout.</p>
+<p><center><img src="/figures/ch3/18333fig0308-tn.png"></center><br/> Figura 3-8. HEAD apunta a otra rama cuando hacemos un checkout.</p>
-<p>That command did two things. It moved the HEAD pointer back to point to the master branch, and it reverted the files in your working directory back to the snapshot that master points to. This also means the changes you make from this point forward will diverge from an older version of the project. It essentially rewinds the work you’ve done in your testing branch temporarily so you can go in a different direction.</p>
+<p>Este comando realiza dos acciones: Mueve el apuntador HEAD de nuevo a la rama &#8216;master&#8217;, y revierte los archivos de tu directorio de trabajo; dejandolos tal y como estaban en la última instantánea confirmada en dicha rama &#8216;master&#8217;. Esto supone que los cambios que hagas desde este momento en adelante divergerán de la antigua versión del proyecto. Básicamente, lo que se está haciendo es rebobinar el trabajo que habias hecho temporalmente en la rama &#8216;testing&#8217;; de tal forma que puedas avanzar en otra dirección diferente.</p>
-<p>Let’s make a few changes and commit again:</p>
+<p>Haz algunos cambios más y confirmalos:</p>
<pre><code>$ vim test.rb
$ git commit -a -m &#39;made other changes&#39;</code></pre>
-<p>Now your project history has diverged (see Figure 3-9). You created and switched to a branch, did some work on it, and then switched back to your main branch and did other work. Both of those changes are isolated in separate branches: you can switch back and forth between the branches and merge them together when you’re ready. And you did all that with simple <code>branch</code> and <code>checkout</code> commands.</p>
+<p>Ahora el registro de tu proyecto diverge (ver Figura 3-9). Has creado una rama y saltado a ella, has trabajado sobre ella; has vuelto a la rama original, y has trabajado también sobre ella. Los cambios realizados en ambas sesiones de trabajo están aislados en ramas independientes: puedes saltar libremente de una a otra según estimes oportuno. Y todo ello simplemente con dos comandos: &#8216;git branch&#8217; y &#8216;git checkout&#8217;.</p>
-<p><center><img src="/figures/ch3/18333fig0309-tn.png"></center><br/> Figure 3-9. The branch histories have diverged.</p>
+<p><center><img src="/figures/ch3/18333fig0309-tn.png"></center><br/> Figura 3-9. Los registros de las ramas divergen.</p>
-<p>Because a branch in Git is in actuality a simple file that contains the 40 character SHA-1 checksum of the commit it points to, branches are cheap to create and destroy. Creating a new branch is as quick and simple as writing 41 bytes to a file (40 characters and a newline).</p>
+<p>Debido a que una rama Git es realmente un simple archivo que contiene los 40 caracteres de una suma de control SHA-1, (representando la confirmación de cambios a la que apunta), no cuesta nada el crear y destruir ramas en Git. Crear una nueva rama es tan rápido y simple como escribir 41 bytes en un archivo, (40 caracteres y un retorno de carro).</p>
-<p>This is in sharp contrast to the way most VCS tools branch, which involves copying all of the project’s files into a second directory. This can take several seconds or even minutes, depending on the size of the project, whereas in Git the process is always instantaneous. Also, because we’re recording the parents when we commit, finding a proper merge base for merging is automatically done for us and is generally very easy to do. These features help encourage developers to create and use branches often.</p>
+<p>Esto contrasta fuertemente con los métodos de ramificación usados por otros sistemas de control de versiones. En los que crear una nueva rama supone el copiar todos los archivos del proyecto a una nueva carpeta adiccional. Lo que puede llevar segundos o incluso minutos, dependiendo del tamaño del proyecto. Mientras que en Git el proceso es siempre instantáneo. Y, además, debido a que se almacenan tambien los nodos padre para cada confirmación, el encontrar las bases adecuadas para realizar una fusión entre ramas es un proceso automático y generalmente sencillo de realizar. Animando así a los desarrolladores a utilizar ramificaciones frecuentemente.</p>
-<p>Let’s see why you should do so.</p>
+<p>Y vamos a ver el por qué merece la pena hacerlo así.</p>
<div id='nav'>
<a href='ch3-0.html'>prev</a> | <a href='ch3-2.html'>next</a>
View
104 book/es/ch3-2.html
@@ -1,68 +1,68 @@
---
layout: translation
-title: Pro Git 3.2 Ramificaciones en Git Basic Branching and Merging
+title: Pro Git 3.2 Ramificaciones en Git Procedimientos básicos para ramificar y fusionar
---
-<h2 id='basic_branching_and_merging'>Basic Branching and Merging</h2>
+<h2 id='procedimientos_bsicos_para_ramificar_y_fusionar'>Procedimientos básicos para ramificar y fusionar</h2>
-<p>Let’s go through a simple example of branching and merging with a workflow that you might use in the real world. You’ll follow these steps:</p>
+<p>Vamos a presentar un ejemplo simple de ramificar y de fusionar, con un flujo de trabajo que se podría presentar en la realidad. Imagina que sigues los siquientes pasos:</p>
<ol>
-<li>Do work on a web site.</li>
+<li>Trabajas en un sitio web.</li>
-<li>Create a branch for a new story you’re working on.</li>
+<li>Creas una rama para un nuevo tema sobre el que quieres trabajar.</li>
-<li>Do some work in that branch.</li>
+<li>Realizas algo de trabajo en esa rama.</li>
</ol>
-<p>At this stage, you’ll receive a call that another issue is critical and you need a hotfix. You’ll do the following:</p>
+<p>En este momento, recibes una llamada avisandote de un problema crítico que has de resolver. Y sigues los siguientes pasos:</p>
<ol>
-<li>Revert back to your production branch.</li>
+<li>Vuelves a la rama de producción original.</li>
-<li>Create a branch to add the hotfix.</li>
+<li>Creas una nueva rama para el problema crítico y lo resuelves trabajando en ella.</li>
-<li>After it’s tested, merge the hotfix branch, and push to production.</li>
+<li>Tras las pertinentes pruebas, fusionas (merge) esa rama y la envias (push) a la rama de producción.</li>
-<li>Switch back to your original story and continue working.</li>
+<li>Vuelves a la rama del tema en que andabas antes de la llamada y continuas tu trabajo.</li>
</ol>
-<h3 id='basic_branching'>Basic Branching</h3>
+<h3 id='procedimientos_bsicos_de_ramificacin'>Procedimientos básicos de ramificación</h3>
-<p>First, let’s say you’re working on your project and have a couple of commits already (see Figure 3-10).</p>
+<p>Imagina que estas trabajando en un proyecto, y tienes un par de confirmaciones (commit) ya realizadas. (ver Figura 3-10)</p>
-<p><center><img src="/figures/ch3/18333fig0310-tn.png"></center><br/> Figure 3-10. A short and simple commit history.</p>
+<p><center><img src="/figures/ch3/18333fig0310-tn.png"></center><br/> Figura 3-10. Un registro de confirmaciones simple y corto.</p>
-<p>You’ve decided that you’re going to work on issue #53 in whatever issue-tracking system your company uses. To be clear, Git isn’t tied into any particular issue-tracking system; but because issue #53 is a focused topic that you want to work on, you’ll create a new branch in which to work. To create a branch and switch to it at the same time, you can run the <code>git checkout</code> command with the <code>-b</code> switch:</p>
+<p>Decides trabajar el problema #53, del sistema que tu compañia utiliza para llevar seguimiento de los problemas. Aunque, por supuesto, Git no está ligado a ningún sistema de seguimiento de problemas concreto. Como el problema #53 es un tema concreto y puntual en el que vas a trabajar, creas una nueva rama para él. Para crear una nueva rama y saltar a ella, en un solo paso, puedes utilizar el comando &#8216;git checkout&#8217; con la opción &#8216;-b&#8217;:</p>
<pre><code>$ git checkout -b iss53
Switched to a new branch &quot;iss53&quot;</code></pre>
-<p>This is shorthand for:</p>
+<p>Esto es un atajo a:</p>
<pre><code>$ git branch iss53
$ git checkout iss53</code></pre>
-<p>Figure 3-11 illustrates the result.</p>
+<p>Figura 3-11 muestra el resultado.</p>
-<p><center><img src="/figures/ch3/18333fig0311-tn.png"></center><br/> Figure 3-11. Creating a new branch pointer.</p>
+<p><center><img src="/figures/ch3/18333fig0311-tn.png"></center><br/> Figura 3-11. Creación de un apuntador a la nueva rama.</p>
-<p>You work on your web site and do some commits. Doing so moves the <code>iss53</code> branch forward, because you have it checked out (that is, your HEAD is pointing to it; see Figure 3-12):</p>
+<p>Trabajas en el sitio web y haces algunas confirmaciones de cambios (commits). Con ello avanzas la rama &#8216;iss53&#8217;, que es la que tienes activada (checked out) en este momento (es decir, a la que apunta HEAD; ver Figura 3-12):</p>
<pre><code>$ vim index.html
$ git commit -a -m &#39;added a new footer [issue 53]&#39;</code></pre>
-<p><center><img src="/figures/ch3/18333fig0312-tn.png"></center><br/> Figure 3-12. The iss53 branch has moved forward with your work.</p>
+<p><center><img src="/figures/ch3/18333fig0312-tn.png"></center><br/> Figura 3-12. La rama &#8216;iss53&#8217; ha avanzado con tu trabajo.</p>
-<p>Now you get the call that there is an issue with the web site, and you need to fix it immediately. With Git, you don’t have to deploy your fix along with the <code>iss53</code> changes you’ve made, and you don’t have to put a lot of effort into reverting those changes before you can work on applying your fix to what is in production. All you have to do is switch back to your master branch.</p>
+<p>Entonces, recibes una llamada avisandote de otro problema urgente en el sitio web. Problema que has de resolver inmediatamente. Usando Git, no necesitas mezclar el nuevo problema con los cambios que ya habias realizado sobre el problema #53; ni tampoco perder tiempo revirtiendo esos cambios para poder trabajar sobre el contenido que está en producción. Basta con saltar de nuevo a la rama &#8216;master&#8217; y continuar trabajando a partir de ella.</p>
-<p>However, before you do that, note that if your working directory or staging area has uncommitted changes that conflict with the branch you’re checking out, Git won’t let you switch branches. It’s best to have a clean working state when you switch branches. There are ways to get around this (namely, stashing and commit amending) that we’ll cover later. For now, you’ve committed all your changes, so you can switch back to your master branch:</p>
+<p>Pero, antes de poder hacer eso, hemos de tener en cuenta que teniendo cambios aún no confirmados en la carpeta de trabajo o en el área de preparación, Git no nos permitirá saltar a otra rama con la que podríamos tener conflictos. Lo mejor es tener siempre un estado de trabajo limpio y despejado antes de saltar entre ramas. Y, para ello, tenemos algunos procedimientos (stash y commit ammend), que vamos a ver más adelante. Por ahora, como tenemos confirmados todos los cambios, podemos saltar a la rama &#8216;master&#8217; sin problemas:</p>
<pre><code>$ git checkout master
Switched to branch &quot;master&quot;</code></pre>
-<p>At this point, your project working directory is exactly the way it was before you started working on issue #53, and you can concentrate on your hotfix. This is an important point to remember: Git resets your working directory to look like the snapshot of the commit that the branch you check out points to. It adds, removes, and modifies files automatically to make sure your working copy is what the branch looked like on your last commit to it.</p>
+<p>Tras esto, tendrás la carpeta de trabajo exactamente igual a como estaba antes de comenzar a trabajar sobre el problema #53. Y podrás concentrarte en el nuevo problema urgente. Es importante recordar que Git revierte la carpeta de trabajo exactamente al estado en que estaba en la confirmación (commit) apuntada por la rama que activamos (checkout) en cada momento. Git añade, quita y modifica archivos automáticamente. Para asegurarte que tu copia de trabajo es exactamente tal y como era la rama en la última confirmación de cambios realizada sobre ella.</p>
-<p>Next, you have a hotfix to make. Let’s create a hotfix branch on which to work until it’s completed (see Figure 3-13):</p>
+<p>Volviendo al problema urgente. Vamos a crear una nueva rama &#8216;hotfix&#8217;, sobre la que trabajar hasta resolverlo (ver Figura 3-13):</p>
<pre><code>$ git checkout -b &#39;hotfix&#39;
Switched to a new branch &quot;hotfix&quot;
@@ -71,9 +71,9 @@ <h3 id='basic_branching'>Basic Branching</h3>
[hotfix]: created 3a0874c: &quot;fixed the broken email address&quot;
1 files changed, 0 insertions(+), 1 deletions(-)</code></pre>
-<p><center><img src="/figures/ch3/18333fig0313-tn.png"></center><br/> Figure 3-13. hotfix branch based back at your master branch point.</p>
+<p><center><img src="/figures/ch3/18333fig0313-tn.png"></center><br/> Figura 3-13. rama &#8216;hotfix&#8217; basada en la rama &#8216;master&#8217; original.</p>
-<p>You can run your tests, make sure the hotfix is what you want, and merge it back into your master branch to deploy to production. You do this with the <code>git merge</code> command:</p>
+<p>Puedes realizar las pruebas oportunas, asegurarte que la solución es correcta, e incorporar los cambios a la rama &#8216;master&#8217; para ponerlos en producción. Esto se hace con el comando &#8216;git merge&#8217;:</p>
<pre><code>$ git checkout master
$ git merge hotfix
@@ -82,18 +82,18 @@ <h3 id='basic_branching'>Basic Branching</h3>
README | 1 -
1 files changed, 0 insertions(+), 1 deletions(-)</code></pre>
-<p>You’ll notice the phrase &#8220;Fast forward&#8221; in that merge. Because the commit pointed to by the branch you merged in was directly upstream of the commit you’re on, Git moves the pointer forward. To phrase that another way, when you try to merge one commit with a commit that can be reached by following the first commit’s history, Git simplifies things by moving the pointer forward because there is no divergent work to merge together — this is called a &#8220;fast forward&#8221;.</p>
+<p>Merece destacar la frase &#8220;Avance rápido&#8221; (&#8220;Fast forward&#8221;) que aparece en la respuesta al comando. Git ha movido el apuntador hacia adelante, ya que la confirmación apuntada en la rama donde has fusionado estaba directamente &#8220;aguas arriba&#8221; respecto de la confirmación actual. Dicho de otro modo: cuando intentas fusionar una confirmación con otra confirmación accesible siguiendo directamente el registro de la primera; Git simplifica las cosas avanzando el puntero, ya que no hay ningûn otro trabajo divergente a fusionar. Esto es lo que se denomina &#8220;avance rápido&#8221; (&#8220;fast forward&#8221;).</p>
-<p>Your change is now in the snapshot of the commit pointed to by the <code>master</code> branch, and you can deploy your change (see Figure 3-14).</p>
+<p>Ahora, los cambios realizados están ya en la instantánea (snapshot) de la confirmación (commit) apuntada por la rama &#8216;master&#8217;. Y puedes desplegarlos (ver Figura 3-14)</p>
-<p><center><img src="/figures/ch3/18333fig0314-tn.png"></center><br/> Figure 3-14. Your master branch points to the same place as your hotfix branch after the merge.</p>
+<p><center><img src="/figures/ch3/18333fig0314-tn.png"></center><br/> Figura 3-14. Tras la fusión (merge), la rama &#8216;master&#8217; apunta al mismo sitio que la rama &#8216;hotfix&#8217;.</p>
-<p>After your super-important fix is deployed, you’re ready to switch back to the work you were doing before you were interrupted. However, first you’ll delete the <code>hotfix</code> branch, because you no longer need it — the <code>master</code> branch points at the same place. You can delete it with the <code>-d</code> option to <code>git branch</code>:</p>
+<p>Tras haber resuelto el problema urgente que te habia interrumpido tu trabajo, puedes volver a donde estabas. Pero antes, es interesante borrar la rama &#8216;hotfix&#8217;. Ya que no la vamos a necesitar más, puesto que apunta exactamente al mismo sitio que la rama &#8216;master&#8217;. Esto lo puedes hacer con la opción &#8216;-d&#8217; del comando &#8216;git branch&#8217;:</p>
<pre><code>$ git branch -d hotfix
Deleted branch hotfix (3a0874c).</code></pre>
-<p>Now you can switch back to your work-in-progress branch on issue #53 and continue working on it (see Figure 3-15):</p>
+<p>Y, con esto, ya estas dispuesto para regresar al trabajo sobre el problema #53 (ver Figura 3-15):</p>
<pre><code>$ git checkout iss53
Switched to branch &quot;iss53&quot;
@@ -102,44 +102,44 @@ <h3 id='basic_branching'>Basic Branching</h3>
[iss53]: created ad82d7a: &quot;finished the new footer [issue 53]&quot;
1 files changed, 1 insertions(+), 0 deletions(-)</code></pre>
-<p><center><img src="/figures/ch3/18333fig0315-tn.png"></center><br/> Figure 3-15. Your iss53 branch can move forward independently.</p>
+<p><center><img src="/figures/ch3/18333fig0315-tn.png"></center><br/> Figura 3-15. La rama &#8216;iss53&#8217; puede avanzar independientemente.</p>
-<p>It’s worth noting here that the work you did in your <code>hotfix</code> branch is not contained in the files in your <code>iss53</code> branch. If you need to pull it in, you can merge your <code>master</code> branch into your <code>iss53</code> branch by running <code>git merge master</code>, or you can wait to integrate those changes until you decide to pull the <code>iss53</code> branch back into <code>master</code> later.</p>
+<p>Cabe indicar que todo el trabajo realizado en la rama &#8216;hotfix&#8217; no está en los archivos de la rama &#8216;iss53&#8217;. Si fuera necesario agregarlos, puedes fusionar (merge) la rama &#8216;master&#8217; sobre la rama &#8216;iss53&#8217; utilizando el comando &#8216;git merge master&#8217;. O puedes esperar hasta que decidas llevar (pull) la rama &#8216;iss53&#8217; a la rama &#8216;master&#8217;.</p>
-<h3 id='basic_merging'>Basic Merging</h3>
+<h3 id='procedimientos_bsicos_de_fusin'>Procedimientos básicos de fusión</h3>
-<p>Suppose you’ve decided that your issue #53 work is complete and ready to be merged into your <code>master</code> branch. In order to do that, you’ll merge in your <code>iss53</code> branch, much like you merged in your <code>hotfix</code> branch earlier. All you have to do is check out the branch you wish to merge into and then run the <code>git merge</code> command:</p>
+<p>Supongamos que tu trabajo con el problema #53 está ya completo y listo para fusionarlo (merge) con la rama &#8216;master&#8217;. Para ello, de forma similar a como antes has hecho con la rama &#8216;hotfix&#8217;, vas a fusionar la rama &#8216;iss53&#8217;. Simplemente, activando (checkout) la rama donde deseas fusionar y lanzando el comando &#8216;git merge&#8217;:</p>
<pre><code>$ git checkout master
$ git merge iss53
Merge made by recursive.
README | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)</code></pre>
-<p>This looks a bit different than the <code>hotfix</code> merge you did earlier. In this case, your development history has diverged from some older point. Because the commit on the branch you’re on isn’t a direct ancestor of the branch you’re merging in, Git has to do some work. In this case, Git does a simple three-way merge, using the two snapshots pointed to by the branch tips and the common ancestor of the two. Figure 3-16 highlights the three snapshots that Git uses to do its merge in this case.</p>
+<p>Es algo diferente de la fusión realizada anteriormente con &#8216;hotfix&#8217;. En este caso, el registro de desarrollo habia divergido en un punto anterior. Debido a que la confirmación en la rama actual no es ancestro directo de la rama que pretendes fusionar, Git tiene cierto trabajo extra que hacer. Git realizará una fusión a tres bandas, utilizando las dos instantáneas apuntadas por el extremo de cada una de las ramas y por el ancestro común a ambas dos. La figura 3-16 ilustra las tres instantáneas que Git utiliza para realizar la fusión en este caso.</p>
-<p><center><img src="/figures/ch3/18333fig0316-tn.png"></center><br/> Figure 3-16. Git automatically identifies the best common-ancestor merge base for branch merging.</p>
+<p><center><img src="/figures/ch3/18333fig0316-tn.png"></center><br/> Figura 3-16. Git identifica automáticamente el mejor ancestro común para realizar la fusión de las ramas.</p>
-<p>Instead of just moving the branch pointer forward, Git creates a new snapshot that results from this three-way merge and automatically creates a new commit that points to it (see Figure 3-17). This is referred to as a merge commit and is special in that it has more than one parent.</p>
+<p>En lugar de simplemente avanzar el apuntador de la rama, Git crea una nueva instantánea (snapshot) resultante de la fusión a tres bandas; y crea automáticamente una nueva confirmación de cambios (commit) que apunta a ella. Nos referimos a este proceso como &#8220;fusión confirmada&#8221;. Y se diferencia en que tiene más de un padre.</p>
-<p>It’s worth pointing out that Git determines the best common ancestor to use for its merge base; this is different than CVS or Subversion (before version 1.5), where the developer doing the merge has to figure out the best merge base for themselves. This makes merging a heck of a lot easier in Git than in these other systems.</p>
+<p>Merece la pena destacar el hecho de que es el propio Git quien determina automáticamente el mejor ancestro común para realizar la fusión. Diferenciandose de otros sistemas tales como CVS o Subversion, donde es el desarrollador quien ha de imaginarse cuál puede ser dicho mejor ancestro común. Esto hace que en Git sea mucho más facil el realizar fusiones.</p>
-<p><center><img src="/figures/ch3/18333fig0317-tn.png"></center><br/> Figure 3-17. Git automatically creates a new commit object that contains the merged work.</p>
+<p><center><img src="/figures/ch3/18333fig0317-tn.png"></center><br/> Figura 3-17. Git crea automáticamente una nueva confirmación para la fusión.</p>
-<p>Now that your work is merged in, you have no further need for the <code>iss53</code> branch. You can delete it and then manually close the ticket in your ticket-tracking system:</p>
+<p>Ahora que todo tu trabajo está ya fusionado con la rama principal, ya no tienes necesidad de la rama &#8216;iss53&#8217;. Por lo que puedes borrarla. Y cerrar manualmente el problema en el sistema de seguimiento de problemas de tu empresa.</p>
<pre><code>$ git branch -d iss53</code></pre>
-<h3 id='basic_merge_conflicts'>Basic Merge Conflicts</h3>
+<h3 id='principales_conflictos_que_pueden_surgir_en_las_fusiones'>Principales conflictos que pueden surgir en las fusiones</h3>
-<p>Occasionally, this process doesn’t go smoothly. If you changed the same part of the same file differently in the two branches you’re merging together, Git won’t be able to merge them cleanly. If your fix for issue #53 modified the same part of a file as the <code>hotfix</code>, you’ll get a merge conflict that looks something like this:</p>
+<p>En algunas ocasiones, los procesos de fusión no suelen ser fluidos. Si hay modificaciones dispares en una misma porción de un mismo archivo en las dos ramas distintas que pretendes fusionar, Git no será capaz de fusionarlas directamente. Por ejemplo, si en tu trabajo del problema #53 has modificado una misma porción que también ha sido modificada en el problema &#8216;hotfix&#8217;. Puedes obtener un conflicto de fusión tal que:</p>
<pre><code>$ git merge iss53
Auto-merging index.html
CONFLICT (content): Merge conflict in index.html
Automatic merge failed; fix conflicts and then commit the result.</code></pre>
-<p>Git hasn’t automatically created a new merge commit. It has paused the process while you resolve the conflict. If you want to see which files are unmerged at any point after a merge conflict, you can run <code>git status</code>:</p>
+<p>Git no crea automáticamente una nueva fusión confirmada (merge commit). Sino que hace una pausa en el proceso, esperando a que tu resuelvas el conflicto. Para ver qué archivos permanecen sin fusionar en un determinado momento conflictivo de una fusión, puedes usar el comando &#8216;git status&#8217;:</p>
<pre><code>[master*]$ git status
index.html: needs merge
@@ -151,7 +151,7 @@ <h3 id='basic_merge_conflicts'>Basic Merge Conflicts</h3>
# unmerged: index.html
#</code></pre>
-<p>Anything that has merge conflicts and hasn’t been resolved is listed as unmerged. Git adds standard conflict-resolution markers to the files that have conflicts, so you can open them manually and resolve those conflicts. Your file contains a section that looks something like this:</p>
+<p>Todo aquello que sea conflictivo y no se haya podido resolver, se marca como &#8220;sin fusionar&#8221; (unmerged). Git añade a los archivos conflictivos unos marcadores especiales de resolución de conflictos. Marcadores que te guiarán cuando abras manualmente los archivos implicados y los edites para corregirlos. El archivo conflictivo contendrá algo como:</p>
<pre><code>&lt;&lt;&lt;&lt;&lt;&lt;&lt; HEAD:index.html
&lt;div id=&quot;footer&quot;&gt;contact : email.support@github.com&lt;/div&gt;
@@ -161,13 +161,13 @@ <h3 id='basic_merge_conflicts'>Basic Merge Conflicts</h3>
&lt;/div&gt;
&gt;&gt;&gt;&gt;&gt;&gt;&gt; iss53:index.html</code></pre>
-<p>This means the version in HEAD (your master branch, because that was what you had checked out when you ran your merge command) is the top part of that block (everything above the <code>=======</code>), while the version in your <code>iss53</code> branch looks like everything in the bottom part. In order to resolve the conflict, you have to either choose one side or the other or merge the contents yourself. For instance, you might resolve this conflict by replacing the entire block with this:</p>
+<p>Donde nos dice que la versión en HEAD (la rama &#8216;master&#8217;, la que habias activado antes de lanzar el comando de fusión), contiene lo indicado en la parte superior del bloque (todo lo que está encima de &#8216;=======&#8217;). Y que la versión en &#8216;iss53&#8217; contiene el resto, lo indicado en la parte inferior del bloque. Para resolver el conflicto, has de elegir manualmente contenido de uno o de otro lado. Por ejemplo, puedes optar por cambiar el bloque, dejandolo tal que:</p>
<pre><code>&lt;div id=&quot;footer&quot;&gt;
please contact us at email.support@github.com
&lt;/div&gt;</code></pre>
-<p>This resolution has a little of each section, and I’ve fully removed the <code>&lt;&lt;&lt;&lt;&lt;&lt;&lt;</code>, <code>=======</code>, and <code>&gt;&gt;&gt;&gt;&gt;&gt;&gt;</code> lines. After you’ve resolved each of these sections in each conflicted file, run <code>git add</code> on each file to mark it as resolved. Staging the file marks it as resolved in Git. If you want to use a graphical tool to resolve these issues, you can run <code>git mergetool</code>, which fires up an appropriate visual merge tool and walks you through the conflicts:</p>
+<p>Esta corrección contiene un poco de ambas partes. Y se han eliminado completamente las líneas <code>&lt;&lt;&lt;&lt;&lt;&lt;&lt;</code> , <code>=======</code> y <code>&gt;&gt;&gt;&gt;&gt;&gt;&gt;</code> Tras resolver todos los bloques conflictivos, has de lanzar comandos &#8216;git add&#8217; para marcar cada archivo modificado. Marcar archivos como preparados (staging), indica a Git que sus conflictos han sido resueltos. Si, en lugar de resolver directamente, prefieres utilizar una herramienta gráfica. Puedes usar el comando &#8216;git mergetool&#8217;. Esto arrancará la correspondiente herramienta de visualización y te permirá ir resolviendo conflictos con ella.</p>
<pre><code>$ git mergetool
merge tool candidates: kdiff3 tkdiff xxdiff meld gvimdiff opendiff emerge vimdiff
@@ -178,11 +178,11 @@ <h3 id='basic_merge_conflicts'>Basic Merge Conflicts</h3>
{remote}: modified
Hit return to start merge resolution tool (opendiff):</code></pre>
-<p>If you want to use a merge tool other than the default (Git chose <code>opendiff</code> for me in this case because I ran the command on a Mac), you can see all the supported tools listed at the top after “merge tool candidates”. Type the name of the tool you’d rather use. In Chapter 7, we’ll discuss how you can change this default value for your environment.</p>
+<p>Si deseas usar una herramienta distinta de la escogida por defecto (en mi caso &#8216;opendiff&#8217;, porque estoy lanzando el comando en un Mac), puedes escogerla entre la lista de herramientas soportadas mostradas al principio (&#8220;merge tool candidates&#8221;). Tecleando el nombre de dicha herramienta. En el capítulo 7 se verá cómo cambiar este valor por defecto de tu entorno de trabajo.</p>
-<p>After you exit the merge tool, Git asks you if the merge was successful. If you tell the script that it was, it stages the file to mark it as resolved for you.</p>
+<p>Tras salir de la herramienta de fusionado, Git preguntará a ver si hemos resuelto todos los conflictos y la fusión ha sido satisfactoria. Si le indicas que así ha sido, Git marca como preparado (staged) el archivo que acabamos de modificar.</p>
-<p>You can run <code>git status</code> again to verify that all conflicts have been resolved:</p>
+<p>En cualquier momento, puedes lanzar el comando &#8216;git status&#8217; para ver si ya has resuelto todos los conflictos:</p>
<pre><code>$ git status
# On branch master
@@ -192,7 +192,7 @@ <h3 id='basic_merge_conflicts'>Basic Merge Conflicts</h3>
# modified: index.html
#</code></pre>
-<p>If you’re happy with that, and you verify that everything that had conflicts has been staged, you can type <code>git commit</code> to finalize the merge commit. The commit message by default looks something like this:</p>
+<p>Si todo ha ido correctamente, y ves que todos los archivos conflictivos están marcados como preparados, puedes lanzar el comando &#8216;git commit&#8217; para terminar de confirmar la fusión. El mensaje de confirmación por defecto será algo parecido a:</p>
<pre><code>Merge branch &#39;iss53&#39;
@@ -205,7 +205,7 @@ <h3 id='basic_merge_conflicts'>Basic Merge Conflicts</h3>
# and try again.
#</code></pre>
-<p>You can modify that message with details about how you resolved the merge if you think it would be helpful to others looking at this merge in the future — why you did what you did, if it’s not obvious.</p>
+<p>Puedes modificar este mensaje añadiendo detalles sobre cómo has resuelto la fusión, si lo consideras util para que otros entiendan esta fusión en un futuro. Se trata de indicar porqué has hecho lo que has hecho; a no ser que resulte obvio, claro está.</p>
<div id='nav'>
<a href='ch3-1.html'>prev</a> | <a href='ch3-3.html'>next</a>
View
20 book/es/ch3-3.html
@@ -1,45 +1,45 @@
---
layout: translation
-title: Pro Git 3.3 Ramificaciones en Git Branch Management
+title: Pro Git 3.3 Ramificaciones en Git Gestión de ramificaciones
---
-<h2 id='branch_management'>Branch Management</h2>
+<h2 id='gestin_de_ramificaciones'>Gestión de ramificaciones</h2>
-<p>Now that you’ve created, merged, and deleted some branches, let’s look at some branch-management tools that will come in handy when you begin using branches all the time.</p>
+<p>Ahora que ya has creado, fusionado y borrado algunas ramas, vamos a dar un vistazo a algunas herramientas de gestión muy útiles cuando comienzas a utilizar ramas profusamente.</p>
-<p>The <code>git branch</code> command does more than just create and delete branches. If you run it with no arguments, you get a simple listing of your current branches:</p>
+<p>El comando &#8216;git branch&#8217; tiene más funciones que las de crear y borrar ramas. Si lo lanzas sin argumentos, obtienes una lista de las ramas presentes en tu proyecto:</p>
<pre><code>$ git branch
iss53
* master
testing</code></pre>
-<p>Notice the <code>*</code> character that prefixes the <code>master</code> branch: it indicates the branch that you currently have checked out. This means that if you commit at this point, the <code>master</code> branch will be moved forward with your new work. To see the last commit on each branch, you can run <code>git branch –v</code>:</p>
+<p>Fijate en el carácter &#8217;<em>&#8217; delante de la rama &#8216;master&#8217;: nos indica la rama activa en este momento. Si hacemos una confirmación de cambios (commit), esa será la rama que avance. Para ver la última confirmación de cambios en cada rama, puedes usar el comando &#8216;git branch -v&#8217;:</em></p>
<pre><code>$ git branch -v
iss53 93b412c fix javascript issue
* master 7a98805 Merge branch &#39;iss53&#39;
testing 782fd34 add scott to the author list in the readmes</code></pre>
-<p>Another useful option to figure out what state your branches are in is to filter this list to branches that you have or have not yet merged into the branch you’re currently on. The useful <code>--merged</code> and <code>--no-merged</code> options have been available in Git since version 1.5.6 for this purpose. To see which branches are already merged into the branch you’re on, you can run <code>git branch merged</code>:</p>
+<p>Otra opción útil para averiguar el estado de las ramas, es filtrarlas y mostrar solo aquellas que han sido fusionadas (o que no lo han sido) con la rama actualmente activa. Para ello, Git dispone, desde la versión 1.5.6, las opciones &#8217;&#8211;merged&#8217; y &#8217;&#8211;no-merged&#8217;. Si deseas ver las ramas que han sido fusionadas en la rama activa, puedes lanzar el comando &#8216;git branch &#8211;merged&#8217;:</p>
<pre><code>$ git branch --merged
iss53
* master</code></pre>
-<p>Because you already merged in <code>iss53</code> earlier, you see it in your list. Branches on this list without the <code>*</code> in front of them are generally fine to delete with <code>git branch -d</code>; you’ve already incorporated their work into another branch, so you’re not going to lose anything.</p>
+<p>Aparece la rama &#8216;iss53&#8217; porque ya ha sido fusionada. Y no lleva por delante el caracter &#8217;<em>&#8217; porque todo su contenido ya ha sido incorporado a otras ramas. Podemos borrarla tranquilamente con &#8216;git branch -d&#8217;, sin miedo a perder nada.</em></p>
-<p>To see all the branches that contain work you haven’t yet merged in, you can run <code>git branch --no-merged</code>:</p>
+<p>Para mostrar todas las ramas que contienen trabajos sin fusionar aún, puedes utilizar el comando &#8216;git branch &#8211;no-merged&#8217;:</p>
<pre><code>$ git branch --no-merged
testing</code></pre>
-<p>This shows your other branch. Because it contains work that isn’t merged in yet, trying to delete it with <code>git branch -d</code> will fail:</p>
+<p>Esto nos muestra la otra rama en el proyecto. Debido a que contiene trabajos sin fusionar aún, al intentarla borrar con &#8216;git branch -d&#8217;, el comando nos dará un error:</p>
<pre><code>$ git branch -d testing
error: The branch &#39;testing&#39; is not an ancestor of your current HEAD.
If you are sure you want to delete it, run &#39;git branch -D testing&#39;.</code></pre>
-<p>If you really do want to delete the branch and lose that work, you can force it with <code>-D</code>, as the helpful message points out.</p>
+<p>Si realmente deseas borrar la rama, y perder el trabajo contenido en ella, puedes forzar el borrado con la opción &#8216;-D&#8217;; tal y como lo indica el mensaje de ayuda.</p>
<div id='nav'>
<a href='ch3-2.html'>prev</a> | <a href='ch3-4.html'>next</a>
View
38 book/es/ch3-4.html
@@ -1,42 +1,42 @@
---
layout: translation
-title: Pro Git 3.4 Ramificaciones en Git Branching Workflows
+title: Pro Git 3.4 Ramificaciones en Git Flujos de trabajo ramificados
---
-<h2 id='branching_workflows'>Branching Workflows</h2>
+<h2 id='flujos_de_trabajo_ramificados'>Flujos de trabajo ramificados</h2>
-<p>Now that you have the basics of branching and merging down, what can or should you do with them? In this section, we’ll cover some common workflows that this lightweight branching makes possible, so you can decide if you would like to incorporate it into your own development cycle.</p>
+<p>Ahora que ya has visto los procedimientos básicos de ramificación y fusión, ¿qué puedes o qué debes hacer con ellos? En este apartado vamos a ver algunos de los flujos de trabajo más comunes, de tal forma que puedas decidir si te gustaría incorporar alguno de ellos a tu ciclo de desarrollo.</p>
-<h3 id='longrunning_branches'>Long-Running Branches</h3>
+<h3 id='ramas_de_largo_recorrido'>Ramas de largo recorrido</h3>
-<p>Because Git uses a simple three-way merge, merging from one branch into another multiple times over a long period is generally easy to do. This means you can have several branches that are always open and that you use for different stages of your development cycle; you can merge regularly from some of them into others.</p>
+<p>Por la sencillez de la fusión a tres bandas de Git, el fusionar de una rama a otra multitud de veces a lo largo del tiempo es facil de hacer. Esto te posibilita tener varias ramas siempre abiertas, e irlas usando en diferentes etapas del ciclo de desarrollo; realizando frecuentes fusiones entre ellas.</p>
-<p>Many Git developers have a workflow that embraces this approach, such as having only code that is entirely stable in their <code>master</code> branch — possibly only code that has been or will be released. They have another parallel branch named develop or next that they work from or use to test stability — it isn’t necessarily always stable, but whenever it gets to a stable state, it can be merged into <code>master</code>. It’s used to pull in topic branches (short-lived branches, like your earlier <code>iss53</code> branch) when they’re ready, to make sure they pass all the tests and don’t introduce bugs.</p>
+<p>Muchos desarrolladores que usan Git llevan un flujo de trabajo de esta naturaleza, manteniendo en la rama &#8216;master&#8217; únicamente el código totalmente estable (el código que ha sido o que va a ser liberado). Teniendo otras ramas paralelas denominadas &#8216;desarrollo&#8217; o &#8216;siguiente&#8217;, en las que trabajan y realizan pruebas. Estas ramas paralelas no suele estar siempre en un estado estable; pero cada vez que sí lo están, pueden ser fusionadas con la rama &#8216;master&#8217;. También es habitual el incorporarle (pull) ramas puntuales (ramas temporales, como la rama &#8216;iss53&#8217; del anterior ejemplo) cuando las completamos y estamos seguros de que no van a introducir errores.</p>
-<p>In reality, we’re talking about pointers moving up the line of commits you’re making. The stable branches are farther down the line in your commit history, and the bleeding-edge branches are farther up the history (see Figure 3-18).</p>
+<p>En realidad, en todo momento estamos hablando simplemente de apuntadores moviendose por la línea temporal de confirmaciones de cambio (commit history). Las ramas estables apuntan hacia posiciones más antiguas en el registro de confirmaciones. Mientras que las ramas avanzadas, las que van abriendo camino, apuntan hacia posiciones más recientes.</p>
-<p><center><img src="/figures/ch3/18333fig0318-tn.png"></center><br/> Figure 3-18. More stable branches are generally farther down the commit history.</p>
+<p><center><img src="/figures/ch3/18333fig0318-tn.png"></center><br/> Figura 3-18. Las ramas más estables apuntan hacia posiciones más antiguas en el registro de cambios.</p>
-<p>It’s generally easier to think about them as work silos, where sets of commits graduate to a more stable silo when they’re fully tested (see Figure 3-19).</p>
+<p>Podría ser más sencillo pensar en las ramas como si fueran silos de almacenamiento. Donde grupos de confirmaciones de cambio (commits) van promocionando hacia silos más estables a medida que son probados y depurados (ver Figura 3-19)</p>
-<p><center><img src="/figures/ch3/18333fig0319-tn.png"></center><br/> Figure 3-19. It may be helpful to think of your branches as silos.</p>
+<p><center><img src="/figures/ch3/18333fig0319-tn.png"></center><br/> Figura 3-19. Puede ayudar pensar en las ramas como silos de almacenamiento.</p>
-<p>You can keep doing this for several levels of stability. Some larger projects also have a <code>proposed</code> or <code>pu</code> (proposed updates) branch that has integrated branches that may not be ready to go into the <code>next</code> or <code>master</code> branch. The idea is that your branches are at various levels of stability; when they reach a more stable level, they’re merged into the branch above them. Again, having multiple long-running branches isn’t necessary, but it’s often helpful, especially when you’re dealing with very large or complex projects.</p>
+<p>Este sistema de trabajo se puede ampliar para diversos grados de estabilidad. Algunos proyectos muy grandes suelen tener una rama denominada &#8216;propuestas&#8217; o &#8216;pu&#8217; (proposed updates). Donde suele estar todo aquello integrado desde otras ramas, pero que aún no está listo para ser incorporado a las ramas &#8216;siguiente&#8217; o &#8216;master&#8217;. La idea es mantener siempre diversas ramas en diversos grados de estabilidad; pero cuando alguna alcanza un estado más estable, la fusionamos con la rama inmediatamente superior a ella. Aunque no es obligatorio el trabajar con ramas de larga duración, realmente es práctico y útil. Sobre todo en proyectos largos o complejos.</p>
-<h3 id='topic_branches'>Topic Branches</h3>
+<h3 id='ramas_puntuales'>Ramas puntuales</h3>
-<p>Topic branches, however, are useful in projects of any size. A topic branch is a short-lived branch that you create and use for a single particular feature or related work. This is something you’ve likely never done with a VCS before because it’s generally too expensive to create and merge branches. But in Git it’s common to create, work on, merge, and delete branches several times a day.</p>
+<p>Las ramas puntuales, en cambio, son útiles en proyectos de cualquier tamaño. Una rama puntual es aquella de corta duración que abres para un tema o para una funcionalidad muy concretos. Es algo que nunca habrías hecho en otro sistema VCS, debido a los altos costos de crear y fusionar ramas que se suelen dar en esos sistemas. Pero en Git, por el contrario, es muy habitual el crear, trabajar con, fusionar y borrar ramas varias veces al día.</p>
-<p>You saw this in the last section with the <code>iss53</code> and <code>hotfix</code> branches you created. You did a few commits on them and deleted them directly after merging them into your main branch. This technique allows you to context-switch quickly and completely — because your work is separated into silos where all the changes in that branch have to do with that topic, it’s easier to see what has happened during code review and such. You can keep the changes there for minutes, days, or months, and merge them in when they’re ready, regardless of the order in which they were created or worked on.</p>
+<p>Tal y como has visto con las ramas &#8216;iss53&#8217; y &#8216;hotfix&#8217; que has creado en la sección anterior. Has hecho unas pocas confirmaciones de cambio en ellas, y luego las has borrado tras fusionarlas con la rama principal. Esta técnica te posibilita realizar rápidos y completos saltos de contexto. Y, debido a que el trabajo está claramente separado en silos, con todos los cambios de cada tema en su propia rama, te será mucho más sencillo revisar el código y seguir su evolución. Puedes mantener los cambios ahí durante minutos, dias o meses; y fusionarlos cuando realmente estén listos. En lugar de verte obligado a fusionarlos en el orden en que fueron creados y comenzaste a trabajar en ellos.</p>
-<p>Consider an example of doing some work (on <code>master</code>), branching off for an issue (<code>iss91</code>), working on it for a bit, branching off the second branch to try another way of handling the same thing (<code>iss91v2</code>), going back to your master branch and working there for a while, and then branching off there to do some work that you’re not sure is a good idea (<code>dumbidea</code> branch). Your commit history will look something like Figure 3-20.</p>
+<p>Por ejemplo, puedes realizar cierto trabajo en la rama &#8216;master&#8217;, ramificar para un problema concreto (rama &#8216;iss91&#8217;), trabajar en él un rato, ramificar a una segunda rama para probar otra manera de resolverlo (rama &#8216;iss92v2&#8217;), volver a la rama &#8216;master&#8217; y trabajar un poco más, y, por último, ramificar temporalmente para probar algo de lo que no estás seguro (rama &#8216;dumbidea&#8217;). El registro de confirmaciones (commit history) será algo parecido a la Figura 3-20.</p>
-<p><center><img src="/figures/ch3/18333fig0320-tn.png"></center><br/> Figure 3-20. Your commit history with multiple topic branches.</p>
+<p><center><img src="/figures/ch3/18333fig0320-tn.png"></center><br/> Figura 3-20. El registro de confirmaciones con múltiples ramas puntuales.</p>
-<p>Now, let’s say you decide you like the second solution to your issue best (<code>iss91v2</code>); and you showed the <code>dumbidea</code> branch to your coworkers, and it turns out to be genius. You can throw away the original <code>iss91</code> branch (losing commits C5 and C6) and merge in the other two. Your history then looks like Figure 3-21.</p>
+<p>En este momento, supongamos que te decides por la segunda solución al problema (rama &#8216;iss92v2&#8217;); y que, tras mostrar la rama &#8216;dumbidea&#8217; a tus compañeros, resulta que les parece una idea genial. Puedes descartar la rama &#8216;iss91&#8217; (perdiendo las confirmaciones C5 y C6), y fusionar las otras dos. El registro será algo parecido a la Figura 3-21.</p>
-<p><center><img src="/figures/ch3/18333fig0321-tn.png"></center><br/> Figure 3-21. Your history after merging in dumbidea and iss91v2.</p>
+<p><center><img src="/figures/ch3/18333fig0321-tn.png"></center><br/> Figura 3-21. El registro tras fusionar &#8216;dumbidea&#8217; e &#8216;iss91v2&#8217;.</p>
-<p>It’s important to remember when you’re doing all this that these branches are completely local. When you’re branching and merging, everything is being done only in your Git repository — no server communication is happening.</p>
+<p>Es importante recordar que, mientras estás haciendo todo esto, todas las ramas son completamente locales. Cuando ramificas y fusionas, todo se realiza en tu propio repositório Git. No hay nigún tipo de tráfico con ningún servidor.</p>
<div id='nav'>
<a href='ch3-3.html'>prev</a> | <a href='ch3-5.html'>next</a>
View
64 book/es/ch3-5.html
@@ -1,38 +1,38 @@
---
layout: translation
-title: Pro Git 3.5 Ramificaciones en Git Remote Branches
+title: Pro Git 3.5 Ramificaciones en Git Ramas Remotas
---
-<h2 id='remote_branches'>Remote Branches</h2>
+<h2 id='ramas_remotas'>Ramas Remotas</h2>
-<p>Remote branches are references to the state of branches on your remote repositories. They’re local branches that you can’t move; they’re moved automatically whenever you do any network communication. Remote branches act as bookmarks to remind you where the branches on your remote repositories were the last time you connected to them.</p>
+<p>Las ramas remotas son referencias al estado de ramas en tus repositorios remotos. Son ramas locales que no puedes mover; se mueven automáticamente cuando estableces comunicaciones en la red. Las ramas remotas funcionan como marcadores, para recordarte en qué estado se encontraban tus repositorios remotos la última vez que conectaste con ellos.</p>
-<p>They take the form <code>(remote)/(branch)</code>. For instance, if you wanted to see what the <code>master</code> branch on your <code>origin</code> remote looked like as of the last time you communicated with it, you would check the <code>origin/master</code> branch. If you were working on an issue with a partner and they pushed up an <code>iss53</code> branch, you might have your own local <code>iss53</code> branch; but the branch on the server would point to the commit at <code>origin/iss53</code>.</p>
+<p>Suelen referenciarse como &#8216;(remoto)/(rama)&#8217;. Por ejemplo, si quieres saber cómo estaba la rama &#8216;master&#8217; en el remoto &#8216;origin&#8217;. Puedes revisar la rama &#8216;origin/master&#8217;. O si estás trabajando en un problema con un compañero y este envia (push) una rama &#8216;iss53&#8217;, tu tendrás tu propia rama de trabajo local &#8216;iss53&#8217;; pero la rama en el servidor apuntará a la última confirmación (commit) en la rama &#8216;origin/iss53&#8217;.</p>
-<p>This may be a bit confusing, so let’s look at an example. Let’s say you have a Git server on your network at <code>git.ourcompany.com</code>. If you clone from this, Git automatically names it <code>origin</code> for you, pulls down all its data, creates a pointer to where its <code>master</code> branch is, and names it <code>origin/master</code> locally; and you can’t move it. Git also gives you your own <code>master</code> branch starting at the same place as origin’s <code>master</code> branch, so you have something to work from (see Figure 3-22).</p>
+<p>Esto puede ser un tanto confuso, pero intentemos aclararlo con un ejemplo. Supongamos que tienes un sevidor Git en tu red, en &#8216;git.ourcompany.com&#8217;. Si haces un clón desde ahí, Git automáticamente lo denominará &#8216;origin&#8217;, traerá (pull) sus datos, creará un apuntador hacia donde esté en ese momento su rama &#8216;master&#8217;, denominará la copia local &#8216;origin/master&#8217;; y será inamovible para tí. Git te proporcionará también tu propia rama &#8216;master&#8217;, apuntando al mismo lugar que la rama &#8216;master&#8217; de &#8216;origin&#8217;; siendo en esta última donde podrás trabajar.</p>
-<p><center><img src="/figures/ch3/18333fig0322-tn.png"></center><br/> Figure 3-22. A Git clone gives you your own master branch and origin/master pointing to origin’s master branch.</p>
+<p><center><img src="/figures/ch3/18333fig0322-tn.png"></center><br/> Figura 3-22. Un clón Git te proporciona tu propia rama &#8216;master&#8217; y otra rama &#8216;origin/master&#8217; apuntando a la rama &#8216;master&#8217; original.</p>
-<p>If you do some work on your local master branch, and, in the meantime, someone else pushes to <code>git.ourcompany.com</code> and updates its master branch, then your histories move forward differently. Also, as long as you stay out of contact with your origin server, your <code>origin/master</code> pointer doesn’t move (see Figure 3-23).</p>
+<p>Si haces algún trabajo en tu rama &#8216;master&#8217; local. Y, al mismo tiempo, alguna otra persona lleva (push) su trabajo al servidor &#8216;git.ourcompany.com&#8217;, actualizando la rama &#8216;master&#8217; de allí. Te encontrarás con que ambos registros avanzan de forma diferente. Además, mientras no tengas contacto con el servidor, tu apuntador a tu rama &#8216;origin/master&#8217; no se moverá (ver Figura 3/23).</p>
-<p><center><img src="/figures/ch3/18333fig0323-tn.png"></center><br/> Figure 3-23. Working locally and having someone push to your remote server makes each history move forward differently.</p>
+<p><center><img src="/figures/ch3/18333fig0323-tn.png"></center><br/> Figura 3-23. Trabajando localmente y que otra persona esté llevando (push) algo al servidor remoto, hace que cada registro avance de forma distinta.</p>
-<p>To synchronize your work, you run a <code>git fetch origin</code> command. This command looks up which server origin is (in this case, it’s <code>git.ourcompany.com</code>), fetches any data from it that you don’t yet have, and updates your local database, moving your <code>origin/master</code> pointer to its new, more up-to-date position (see Figure 3-24).</p>
+<p>Para sincronizarte, puedes utilizar el comando &#8216;git fetch origin&#8217;. Este comando localiza en qué servidor está el origen (en este caso &#8216;git.ourcompany.com&#8217;), recupera cualquier dato presente allí que tu no tengas, y actualiza tu base de datos local, moviendo tu rama &#8216;origin/master&#8217; para que apunte a esta nueva y más reciente posición (ver Figura 3-24).</p>
-<p><center><img src="/figures/ch3/18333fig0324-tn.png"></center><br/> Figure 3-24. The git fetch command updates your remote references.</p>
+<p><center><img src="/figures/ch3/18333fig0324-tn.png"></center><br/> Figura 3-24. El comando &#8216;git fetch&#8217; actualiza tus referencias remotas.</p>
-<p>To demonstrate having multiple remote servers and what remote branches for those remote projects look like, let’s assume you have another internal Git server that is used only for development by one of your sprint teams. This server is at <code>git.team1.ourcompany.com</code>. You can add it as a new remote reference to the project you’re currently working on by running the <code>git remote add</code> command as we covered in Chapter 2. Name this remote <code>teamone</code>, which will be your shortname for that whole URL (see Figure 3-25).</p>
+<p>Para ilustrar mejor el caso de tener múltiples servidores y cómo van las ramas remotas para esos proyectos remotos. Supongamos que tienes otro servidor Git; utilizado solamente para desarrollo, por uno de tus equipos sprint. Un servidor en &#8216;git.team1.ourcompany.com&#8217;. Puedes incluirlo como una nueva referencia remota a tu proyecto actual, mediante el comando &#8216;git remote add&#8217;, tal y como vimos en el capítulo 2. Puedes denominar &#8216;teamone&#8217; a este remoto, poniendo este nombre abreviado para la URL (ver Figura 3-25)</p>
-<p><center><img src="/figures/ch3/18333fig0325-tn.png"></center><br/> Figure 3-25. Adding another server as a remote.</p>
+<p><center><img src="/figures/ch3/18333fig0325-tn.png"></center><br/> Figura 3-25. Añadiendo otro servidor como remoto.</p>
-<p>Now, you can run <code>git fetch teamone</code> to fetch everything server has that you don’t have yet. Because that server is a subset of the data your <code>origin</code> server has right now, Git fetches no data but sets a remote branch called <code>teamone/master</code> to point to the commit that <code>teamone</code> has as its <code>master</code> branch (see Figure 3-26).</p>
+<p>Ahora, puedes usar el comando &#8216;git fetch teamone&#8217; para recuperar todo el contenido del servidor que tu no tenias. Debido a que dicho servidor es un subconjunto de de los datos del servidor &#8216;origin&#8217; que tienes actualmente, Git no recupera (fetch) ningún dato; simplemente prepara una rama remota llamada &#8216;teamone/master&#8217; para apuntar a la confirmación (commit) que &#8216;teamone&#8217; tiene en su rama &#8216;master&#8217;.</p>
-<p><center><img src="/figures/ch3/18333fig0326-tn.png"></center><br/> Figure 3-26. You get a reference to teamone’s master branch position locally.</p>
+<p><center><img src="/figures/ch3/18333fig0326-tn.png"></center><br/> Figura 3-26. Obtienes una referencia local a la posición en la rama &#8216;master&#8217; de &#8216;teamone&#8217;.</p>
-<h3 id='pushing'>Pushing</h3>
+<h3 id='publicando'>Publicando</h3>
-<p>When you want to share a branch with the world, you need to push it up to a remote that you have write access to. Your local branches aren’t automatically synchronized to the remotes you write to — you have to explicitly push the branches you want to share. That way, you can use private branches for work you don’t want to share, and push up only the topic branches you want to collaborate on.</p>
+<p>Cuando quieres compartir una rama con el resto del mundo, has de llevarla (push) a un remoto donde tengas permisos de escritura. Tus ramas locales no se sincronizan automáticamente con los remotos en los que escribes. Sino que tienes que llevar (push) expresamente, cada vez, al remoto las ramas que desees compartir. De esta forma, puedes usar ramas privadas para el trabajo que no deseas compartir. Llevando a un remoto tan solo aquellas partes que deseas aportar a los demás.</p>
-<p>If you have a branch named <code>serverfix</code> that you want to work on with others, you can push it up the same way you pushed your first branch. Run <code>git push (remote) (branch)</code>:</p>
+<p>Si tienes una rama llamada &#8216;serverfix&#8217;, con la que vas a trabajar en colaboración; puedes llevarla al remoto de la misma forma que llevaste tu primera rama. Con el comando &#8216;git push (remoto) (rama)&#8217;:</p>
<pre><code>$ git push origin serverfix
Counting objects: 20, done.
@@ -42,9 +42,9 @@ <h3 id='pushing'>Pushing</h3>
To git@github.com:schacon/simplegit.git
* [new branch] serverfix -&gt; serverfix</code></pre>
-<p>This is a bit of a shortcut. Git automatically expands the <code>serverfix</code> branchname out to <code>refs/heads/serverfix:refs/heads/serverfix</code>, which means, “Take my serverfix local branch and push it to update the remote’s serverfix branch.” We’ll go over the <code>refs/heads/</code> part in detail in Chapter 9, but you can generally leave it off. You can also do <code>git push origin serverfix:serverfix</code>, which does the same thing — it says, “Take my serverfix and make it the remote’s serverfix.” You can use this format to push a local branch into a remote branch that is named differently. If you didn’t want it to be called <code>serverfix</code> on the remote, you could instead run <code>git push origin serverfix:awesomebranch</code> to push your local <code>serverfix</code> branch to the <code>awesomebranch</code> branch on the remote project.</p>
+<p>Esto es un poco como un atajo. Git expande automáticamente el nombre de rama &#8216;serverfix&#8217; a &#8216;refs/heads/serverfix:refs/heads/serverfix&#8217;, que significa: &#8220;coge mi rama local &#8216;serverfix&#8217; y actualiza con ella la rama &#8216;serverfix&#8217; del remoto&#8221;. Volveremos más tarde sobre el tema de &#8216;refs/heads/&#8217;, viendolo en detalle en el capítulo 9; aunque puedes ignorarlo por ahora. También puedes hacer &#8216;git push origin serverfix:serverfix&#8217;, que hace lo mismo; es decir: &#8220;coge mi &#8216;serverfix&#8217; y hazlo el &#8216;serverfix&#8217; remoto&#8221;. Puedes utilizar este último formato para llevar una rama local a una rama remota con otro nombre distinto. Si no quieres que se llame &#8216;serverfix&#8217; en el remoto, puedes lanzar, por ejemplo, &#8216;git push origin serverfix:awesomebranch&#8217;; para llevar tu rama &#8216;serverfix&#8217; local a la rama &#8216;awesomebranch&#8217; en el proyecto remoto.</p>
-<p>The next time one of your collaborators fetches from the server, they will get a reference to where the server’s version of <code>serverfix</code> is under the remote branch <code>origin/serverfix</code>:</p>
+<p>La próxima vez que tus colaboradores recuperen desde el servidor, obtendrán una referencia a donde la versión de &#8216;serverfix&#8217; en el servidor esté bajo la rama remota &#8216;origin/serverfix&#8217;:</p>
<pre><code>$ git fetch origin
remote: Counting objects: 20, done.
@@ -54,43 +54,43 @@ <h3 id='pushing'>Pushing</h3>
From git@github.com:schacon/simplegit
* [new branch] serverfix -&gt; origin/serverfix</code></pre>
-<p>It’s important to note that when you do a fetch that brings down new remote branches, you don’t automatically have local, editable copies of them. In other words, in this case, you don’t have a new <code>serverfix</code> branch — you only have an <code>origin/serverfix</code> pointer that you can’t modify.</p>
+<p>Es importante destacar que cuando recuperas (fetch) nuevas ramas remotas, no obtienes automáticamente una copia editable local de las mismas. En otras palabras, en este caso, no tienes una nueva rama &#8216;serverfix&#8217;. Sino que únicamente tienes un puntero no editable a &#8216;origin/serverfix&#8217;.</p>
-<p>To merge this work into your current working branch, you can run <code>git merge origin/serverfix</code>. If you want your own <code>serverfix</code> branch that you can work on, you can base it off your remote branch:</p>
+<p>Para integrar (merge) esto en tu actual rama de trabajo, puedes usar el comando &#8216;git merge origin/serverfix&#8217;. Y si quieres tener tu propia rama &#8216;serverfix&#8217;, donde puedas trabajar, puedes crearla directamente basandote en rama remota:</p>
<pre><code>$ git checkout -b serverfix origin/serverfix
Branch serverfix set up to track remote branch refs/remotes/origin/serverfix.
-Switched to a new branch &quot;serverfix&quot;</code></pre>
+Switched to a new branch &quot;serverfix&quot;Switched to a new branch &quot;serverfix&quot;</code></pre>
-<p>This gives you a local branch that you can work on that starts where <code>origin/serverfix</code> is.</p>
+<p>Esto sí te da una rama local donde puedes trabajar, comenzando donde &#8216;origin/serverfix&#8217; estaba en ese momento.</p>
-<h3 id='tracking_branches'>Tracking Branches</h3>
+<h3 id='haciendo_seguimiento_a_las_ramas'>Haciendo seguimiento a las ramas</h3>
-<p>Checking out a local branch from a remote branch automatically creates what is called a <em>tracking branch</em>. Tracking branches are local branches that have a direct relationship to a remote branch. If you’re on a tracking branch and type git push, Git automatically knows which server and branch to push to. Also, running <code>git pull</code> while on one of these branches fetches all the remote references and then automatically merges in the corresponding remote branch.</p>
+<p>Activando (checkout) una rama local a partir de una rama remota, se crea automáticamente lo que podríamos denominar &#8220;una rama de seguimiento&#8221; (tracking branch). Las ramas de seguimiento son ramas locales que tienen una relación directa con alguna rama remota. Si estás en una rama de seguimiento y tecleas el comando &#8216;git push&#8217;, Git sabe automáticamente a qué servidor y a qué rama ha de llevar los contenidos. Igualmente, tecleando &#8216;git pull&#8217; mientras estamos en una de esas ramas, recupera (fetch) todas las referencias remotas y las consolida (merge) automáticamente en la correspondiente rama remota.</p>
-<p>When you clone a repository, it generally automatically creates a <code>master</code> branch that tracks <code>origin/master</code>. That’s why <code>git push</code> and <code>git pull</code> work out of the box with no other arguments. However, you can set up other tracking branches if you wish — ones that don’t track branches on <code>origin</code> and don’t track the <code>master</code> branch. The simple case is the example you just saw, running <code>git checkout -b [branch] [remotename]/[branch]</code>. If you have Git version 1.6.2 or later, you can also use the <code>--track</code> shorthand:</p>
+<p>Cuando clonas un repositorio, este suele crear automáticamente una rama &#8216;master&#8217; que hace seguimiento de &#8216;origin/master&#8217;. Y es por eso que &#8216;git push&#8217; y &#8216;git pull&#8217; trabajan directamente, sin necesidad de más argumentos. Sin embargo, puedes preparar otras ramas de seguimiento si deseas tener unas que no hagan seguimiento de ramas en &#8216;origin&#8217; y que no sigan a la rama &#8216;master&#8217;. El ejemplo más simple, es el que acabas de ver al lanzar el comando &#8216;git checkout -b <span>rama</span>/<span>rama</span>&#8217;. Si tienes la versión 1.6.2 de Git, o superior, puedes utilizar también el parámetro &#8217;&#8211;track&#8217;:</p>
<pre><code>$ git checkout --track origin/serverfix
Branch serverfix set up to track remote branch refs/remotes/origin/serverfix.
-Switched to a new branch &quot;serverfix&quot;</code></pre>
+Switched to a new branch &quot;serverfix&quot;Switched to a new branch &quot;serverfix&quot;</code></pre>
-<p>To set up a local branch with a different name than the remote branch, you can easily use the first version with a different local branch name:</p>
+<p>Para preparar una rama local con un nombre distinto a la del remoto, puedes utilizar:</p>
<pre><code>$ git checkout -b sf origin/serverfix
Branch sf set up to track remote branch refs/remotes/origin/serverfix.
Switched to a new branch &quot;sf&quot;</code></pre>
-<p>Now, your local branch sf will automatically push to and pull from origin/serverfix.</p>
+<p>Así, tu rama local &#8216;sf&#8217; va a llevar (push) y traer (pull) hacia o desde &#8216;origin/serverfix&#8217;.</p>
-<h3 id='deleting_remote_branches'>Deleting Remote Branches</h3>
+<h3 id='borrando_ramas_remotas'>Borrando ramas remotas</h3>
-<p>Suppose you’re done with a remote branch — say, you and your collaborators are finished with a feature and have merged it into your remote’s <code>master</code> branch (or whatever branch your stable codeline is in). You can delete a remote branch using the rather obtuse syntax <code>git push [remotename] :[branch]</code>. If you want to delete your <code>serverfix</code> branch from the server, you run the following:</p>
+<p>Imagina que ya has terminado con una rama remota. Es decir, tanto tu como tus colaboradores habeis completado una determinada funcionalidad y la habeis incorporado (merge) a la rama &#8216;master&#8217; en el remoto (o donde quiera que tengais la rama de código estable). Puedes borrar la rama remota utilizando la un tanto confusa sintaxis: &#8216;git push <span>nombreremoto</span> :<span>rama</span>&#8217;. Por ejemplo, si quieres borrar la rama &#8216;serverfix&#8217; del servidor, puedes utilizar:</p>
<pre><code>$ git push origin :serverfix
To git@github.com:schacon/simplegit.git
- [deleted] serverfix</code></pre>
-<p>Boom. No more branch on your server. You may want to dog-ear this page, because you’ll need that command, and you’ll likely forget the syntax. A way to remember this command is by recalling the <code>git push [remotename] [localbranch]:[remotebranch]</code> syntax that we went over a bit earlier. If you leave off the <code>[localbranch]</code> portion, then you’re basically saying, “Take nothing on my side and make it be <code>[remotebranch]</code>.”</p>
+<p>Y&#8230;.Boom!. La rama en el servidor ha desaparecido. Puedes grabarte a fuego esta página, porque necesitarás ese comando y, lo más probable es que hayas olvidado su sintaxis. Una manera de recordar este comando es dándonos cuenta de que proviene de la sintaxis &#8216;git push <span>nombreremoto</span>:<span>ramaremota</span>&#8217;. Si omites la parte &#8217;<span>ramalocal</span>&#8217;, lo que estás diciendo es: &#8220;no cojas nada de mi lado y haz con ello <span>ramaremota</span>&#8221;.</p>
<div id='nav'>
<a href='ch3-4.html'>prev</a> | <a href='ch3-6.html'>next</a>
View
92 book/es/ch3-6.html
@@ -1,114 +1,114 @@
---
layout: translation
-title: Pro Git 3.6 Ramificaciones en Git Rebasing
+title: Pro Git 3.6 Ramificaciones en Git Reorganizando el trabajo realizado
---
-<h2 id='rebasing'>Rebasing</h2>
+<h2 id='reorganizando_el_trabajo_realizado'>Reorganizando el trabajo realizado</h2>
-<p>In Git, there are two main ways to integrate changes from one branch into another: the <code>merge</code> and the <code>rebase</code>. In this section you’ll learn what rebasing is, how to do it, why it’s a pretty amazing tool, and in what cases you won’t want to use it.</p>
+<p>En Git tenemos dos formas de integrar cambios de una rama en otra: la fusión (merge) y la reorganización (rebase). En esta sección vas a aprender en qué consiste la reorganización, como utilizarla, por qué es una herramienta sorprendente y en qué casos no es conveniente utilizarla.</p>
-<h3 id='the_basic_rebase'>The Basic Rebase</h3>
+<h3 id='reorganizacin_bsica'>Reorganización básica</h3>
-<p>If you go back to an earlier example from the Merge section (see Figure 3-27), you can see that you diverged your work and made commits on two different branches.</p>
+<p>Volviendo al ejemplo anterior, en la sección sobre fusiones (ver Figura 3-27), puedes ver que has separado tu trabajo y realizado confirmaciones (commit) en dos ramas diferentes.</p>
-<p><center><img src="/figures/ch3/18333fig0327-tn.png"></center><br/> Figure 3-27. Your initial diverged commit history.</p>
+<p><center><img src="/figures/ch3/18333fig0327-tn.png"></center><br/> Figura 3-27. El registro de confirmaciones inicial.</p>
-<p>The easiest way to integrate the branches, as we’ve already covered, is the <code>merge</code> command. It performs a three-way merge between the two latest branch snapshots (C3 and C4) and the most recent common ancestor of the two (C2), creating a new snapshot (and commit), as shown in Figure 3-28.</p>
+<p>La manera más sencilla de integrar ramas, tal y como hemos visto, es el comando &#8216;git merge&#8217;. Realiza una fusión a tres bandas entre las dos últimas instantáneas de cada rama (C3 y C4) y el ancestro común a ambas (C2); creando una nueva instantánea (snapshot) y la correspondiente confirmación (commit), según se muestra en la Figura 3-28.</p>
-<p><center><img src="/figures/ch3/18333fig0328-tn.png"></center><br/> Figure 3-28. Merging a branch to integrate the diverged work history.</p>
+<p><center><img src="/figures/ch3/18333fig0328-tn.png"></center><br/> Figura 3-28. Fusionando una rama para integrar el registro de trabajos divergentes.</p>
-<p>However, there is another way: you can take the patch of the change that was introduced in C3 and reapply it on top of C4. In Git, this is called <em>rebasing</em>. With the <code>rebase</code> command, you can take all the changes that were committed on one branch and replay them on another one.</p>
+<p>Aunque también hay otra forma de hacerlo: puedes coger los cambios introducidos en C3 y reaplicarlos encima de C4. Esto es lo que en Git llamamos <em>reorganizar</em>. Con el comando &#8216;git rebase&#8217;, puedes coger todos los cambios confirmados en una rama, y reaplicarlos sobre otra.</p>
-<p>In this example, you’d run the following:</p>
+<p>Por ejemplo, puedes lanzar los comandos:</p>
<pre><code>$ git checkout experiment
$ git rebase master
First, rewinding head to replay your work on top of it...
Applying: added staged command</code></pre>
-<p>It works by going to the common ancestor of the two branches (the one you’re on and the one you’re rebasing onto), getting the diff introduced by each commit of the branch you’re on, saving those diffs to temporary files, resetting the current branch to the same commit as the branch you are rebasing onto, and finally applying each change in turn. Figure 3-29 illustrates this process.</p>
+<p>Haciendo que Git: vaya al ancestro común de ambas ramas (donde estás actualmente y de donde quieres reorganizar), saque las diferencias introducidas por cada confirmación en la rama donde estás, guarde esas diferencias en archivos temporales, reinicie (reset) la rama actual hasta llevarla a la misma confirmación en la rama de donde quieres reorganizar, y, finalmente, vuelva a aplicar ordenadamente los cambios. El proceso se muestra en la Figura 3-29.</p>
-<p><center><img src="/figures/ch3/18333fig0329-tn.png"></center><br/> Figure 3-29. Rebasing the change introduced in C3 onto C4.</p>
+<p><center><img src="/figures/ch3/18333fig0329-tn.png"></center><br/> Figura 3-29. Reorganizando sobre C4 los cambios introducidos en C3.</p>
-<p>At this point, you can go back to the master branch and do a fast-forward merge (see Figure 3-30).</p>
+<p>En este momento, puedes volver a la rama &#8216;master&#8217; y hacer una fusión con avance rápido (fast-forward merge). (ver Figura 3-30)</p>
-<p><center><img src="/figures/ch3/18333fig0330-tn.png"></center><br/> Figure 3-30. Fast-forwarding the master branch.</p>
+<p><center><img src="/figures/ch3/18333fig0330-tn.png"></center><br/> Figura 3-30. Avance rápido de la rama &#8216;master&#8217;.</p>
-<p>Now, the snapshot pointed to by C3 is exactly the same as the one that was pointed to by C5 in the merge example. There is no difference in the end product of the integration, but rebasing makes for a cleaner history. If you examine the log of a rebased branch, it looks like a linear history: it appears that all the work happened in series, even when it originally happened in parallel.</p>
+<p>Así, la instantánea apuntada por C3 aquí es exactamente la misma apuntada por C5 en el ejemplo de la fusión. No hay ninguna diferencia en el resultado final de la integración, pero el haberla hecho reorganizando nos deja un registro más claro. Si examinas el registro de una rama reorganizada, este aparece siempre como un registro lineal: como si todo el trabajo se hubiera realizado en series, aunque realmente se haya hecho en paralelo.</p>
-<p>Often, you’ll do this to make sure your commits apply cleanly on a remote branch — perhaps in a project to which you’re trying to contribute but that you don’t maintain. In this case, you’d do your work in a branch and then rebase your work onto <code>origin/master</code> when you were ready to submit your patches to the main project. That way, the maintainer doesn’t have to do any integration work — just a fast-forward or a clean apply.</p>
+<p>Habitualmente, optarás por esta vía cuando quieras estar seguro de que tus confirmaciones de cambio (commits) se pueden aplicar limpiamente sobre una rama remota; posiblemente, en un proyecto donde estés intentando colaborar, pero lleves tu el mantenimiento. En casos como esos, puedes trabajar sobre una rama y luego reorgainzar lo realizado en la rama &#8216;origin/master&#8217; cuando lo tengas todo listo para enviarlo al proyecto principal. De esta forma, la persona que mantiene el proyecto no necesitará hacer ninguna integración con tu trabajo; le bastará con un avance rápido o una incorporación limpia.</p>
-<p>Note that the snapshot pointed to by the final commit you end up with, whether it’s the last of the rebased commits for a rebase or the final merge commit after a merge, is the same snapshot — it’s only the history that is different. Rebasing replays changes from one line of work onto another in the order they were introduced, whereas merging takes the endpoints and merges them together.</p>
+<p>Cabe destacar que la instantánea (snapshot) apuntada por la confirmación (commit) final, tanto si es producto de una regorganización (rebase) como si lo es de una fusión (merge), es exactamente la misma instantánea. Lo único diferente es el registro. La reorganización vuelve a aplicar cambios de una rama de trabajo sobre otra rama, en el mismo orden en que fueron introducidos en la primera. Mientras que la fusión combina entre sí los dos puntos finales de ambas ramas.</p>
-<h3 id='more_interesting_rebases'>More Interesting Rebases</h3>
+<h3 id='algunas_otras_reorganizaciones_interesantes'>Algunas otras reorganizaciones interesantes</h3>
-<p>You can also have your rebase replay on something other than the rebase branch. Take a history like Figure 3-31, for example. You branched a topic branch (<code>server</code>) to add some server-side functionality to your project, and made a commit. Then, you branched off that to make the client-side changes (<code>client</code>) and committed a few times. Finally, you went back to your server branch and did a few more commits.</p>
+<p>También puedes aplicar una reorganización (rebase) sobre otra cosa además de sobre la rama de reorganización. Por ejemplo, sea un registro como el de la Figura 3-31. Has ramificado a una rama puntual (&#8216;server&#8217;) para añadir algunas funcionalidades al proyecto, y luego has confirmado los cambios. Despues, vuelves a la rama original para hacer algunos cambios en la parte cliente (rama &#8216;client&#8217;), y confirmas también esos cambios. Por último, vuelves sobre la rama &#8216;server&#8217; y haces algunos cambios más.</p>
-<p><center><img src="/figures/ch3/18333fig0331-tn.png"></center><br/> Figure 3-31. A history with a topic branch off another topic branch.</p>
+<p><center><img src="/figures/ch3/18333fig0331-tn.png"></center><br/> Figura 3-31. Un registro con una rama puntual sobre otra rama puntual.</p>
-<p>Suppose you decide that you want to merge your client-side changes into your mainline for a release, but you want to hold off on the server-side changes until it’s tested further. You can take the changes on client that aren’t on server (C8 and C9) and replay them on your master branch by using the <code>--onto</code> option of <code>git rebase</code>:</p>
+<p>Imagina que decides incorporar tus cambios de la parte cliente sobre el proyecto principal, para hacer un lanzamiento de versión; pero no quieres lanzar aún los cambios de la parte server porque no están aún suficientemente probados. Puedes coger los cambios del cliente que no estan en server (C8 y C9), y reaplicarlos sobre tu rama principal usando la opción &#8217;&#8211;onto&#8217; del comando &#8216;git rebase&#8217;:</p>
<pre><code>$ git rebase --onto master server client</code></pre>
-<p>This basically says, “Check out the client branch, figure out the patches from the common ancestor of the <code>client</code> and <code>server</code> branches, and then replay them onto <code>master</code>.” It’s a bit complex; but the result, shown in Figure 3-32, is pretty cool.</p>
+<p>Esto viene a decir: &#8220;Activa la rama &#8216;client&#8217;, averigua los cambios desde el ancestro común entre las ramas &#8216;client&#8217; y &#8216;server&#8217;, y aplicalos en la rama &#8216;master&#8217;. Puede parecer un poco complicado, pero los resultados, mostrados en la Figura 3-32, son realmente interesantes.</p>
-<p><center><img src="/figures/ch3/18333fig0332-tn.png"></center><br/> Figure 3-32. Rebasing a topic branch off another topic branch.</p>
+<p><center><img src="/figures/ch3/18333fig0332-tn.png"></center><br/> Figura 3-32. Reorganizando una rama puntual fuera de otra rama puntual.</p>
-<p>Now you can fast-forward your master branch (see Figure 3-33):</p>
+<p>Y, tras esto, ya puedes avanzar la rama principal (ver Figura 3-33):</p>
<pre><code>$ git checkout master
$ git merge client</code></pre>
-<p><center><img src="/figures/ch3/18333fig0333-tn.png"></center><br/> Figure 3-33. Fast-forwarding your master branch to include the client branch changes.</p>
+<p><center><img src="/figures/ch3/18333fig0333-tn.png"></center><br/> Figura 3-33. Avance rápido de tu rama &#8216;master&#8217;, para incluir los cambios de la rama &#8216;client&#8217;.</p>
-<p>Let’s say you decide to pull in your server branch as well. You can rebase the server branch onto the master branch without having to check it out first by running <code>git rebase [basebranch] [topicbranch]</code> — which checks out the topic branch (in this case, <code>server</code>) for you and replays it onto the base branch (<code>master</code>):</p>
+<p>Ahora supongamos que decides traerlos (pull) también sobre tu rama &#8216;server&#8217;. Puedes reorganizar (rebase) la rama &#8216;server&#8217; sobre la rama &#8216;master&#8217; sin necesidad siquiera de comprobarlo previamente, usando el comando &#8216;git rebase <span>ramabase</span>&#8217;. El cual activa la rama puntual (&#8216;server&#8217; en este caso) y la aplica sobre la rama base (&#8216;master&#8217; en este caso):</p>
<pre><code>$ git rebase master server</code></pre>
-<p>This replays your <code>server</code> work on top of your <code>master</code> work, as shown in Figure 3-34.</p>
+<p>Esto vuelca el trabajo de &#8216;server&#8217; sobre el de &#8216;master&#8217;, tal y como se muestra en la Figura 3-34.</p>
-<p><center><img src="/figures/ch3/18333fig0334-tn.png"></center><br/> Figure 3-34. Rebasing your server branch on top of your master branch.</p>
+<p><center><img src="/figures/ch3/18333fig0334-tn.png"></center><br/> Figura 3-34. Reorganizando la rama &#8216;server&#8217; sobre la rama &#8216;branch&#8217;.</p>
-<p>Then, you can fast-forward the base branch (<code>master</code>):</p>
+<p>Después, puedes avanzar rápidamente la rama base (&#8216;master&#8217;):</p>
<pre><code>$ git checkout master
$ git merge server</code></pre>
-<p>You can remove the <code>client</code> and <code>server</code> branches because all the work is integrated and you don’t need them anymore, leaving your history for this entire process looking like Figure 3-35:</p>
+<p>Y por último puedes eliminar las ramas &#8216;client&#8217; y &#8216;server&#8217; porque ya todo su contenido ha sido integrado y no las vas a necesitar más. Dejando tu registro tras todo este proceso tal y como se muestra en la Figura 3-35:</p>
<pre><code>$ git branch -d client
$ git branch -d server</code></pre>
-<p><center><img src="/figures/ch3/18333fig0335-tn.png"></center><br/> Figure 3-35. Final commit history.</p>
+<p><center><img src="/figures/ch3/18333fig0335-tn.png"></center><br/> Figura 3-35. Registro final de confirmaciones de cambio.</p>
-<h3 id='the_perils_of_rebasing'>The Perils of Rebasing</h3>
+<h3 id='los_peligros_de_la_reorganizacin'>Los peligros de la reorganización</h3>
-<p>Ahh, but the bliss of rebasing isn’t without its drawbacks, which can be summed up in a single line:</p>
+<p>Ahh&#8230;., pero la dicha de la reorganización no la alcanzamos sin sus contrapartidas:</p>
-<p><strong>Do not rebase commits that you have pushed to a public repository.</strong></p>
+<p><strong>Nunca reorganices confirmaciones de cambio (commits) que hayas enviado (push) a un repositorio público.</strong></p>
-<p>If you follow that guideline, you’ll be fine. If you don’t, people will hate you, and you’ll be scorned by friends and family.</p>
+<p>Siguiendo esta recomendación, no tendrás problemas. Pero si no la sigues, la gente te odiará y serás despreciado por tus familiares y amigos.</p>
-<p>When you rebase stuff, you’re abandoning existing commits and creating new ones that are similar but different. If you push commits somewhere and others pull them down and base work on them, and then you rewrite those commits with <code>git rebase</code> and push them up again, your collaborators will have to re-merge their work and things will get messy when you try to pull their work back into yours.</p>
+<p>Cuando reorganizas algo, estás abandonando las confirmaciones de cambio ya creadas y estás creando unas nuevas; que son similares, pero diferentes. Si envias (push) confirmaciones (commits) a alguna parte, y otros las recogen (pull) de allí. Y después vas tu y las reescribes con &#8216;git rebase&#8217; y las vuelves a enviar (push) de nuevo. Tus colaboradores tendrán que refusionar (re-merge) su trabajo y todo se volverá tremendamente complicado cuando intentes recoger (pull) su trabajo de vuelta sobre el tuyo.</p>
-<p>Let’s look at an example of how rebasing work that you’ve made public can cause problems. Suppose you clone from a central server and then do some work off that. Your commit history looks like Figure 3-36.</p>
+<p>Vamos a verlo con un ejemplo. Imaginate que haces un clon desde un servidor central, y luego trabajas sobre él. Tu registro de cambios puede ser algo como lo de la Figura 3-36.</p>
-<p><center><img src="/figures/ch3/18333fig0336-tn.png"></center><br/> Figure 3-36. Clone a repository, and base some work on it.</p>
+<p><center><img src="/figures/ch3/18333fig0336-tn.png"></center><br/> Figura 3-36. Clonar un repositorio y trabajar sobre él.</p>