﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>BlogJava-Chan Chen Coding...-文章分类-Git</title><link>http://www.blogjava.net/czihong/category/50943.html</link><description /><language>zh-cn</language><lastBuildDate>Tue, 27 Nov 2012 08:59:38 GMT</lastBuildDate><pubDate>Tue, 27 Nov 2012 08:59:38 GMT</pubDate><ttl>60</ttl><item><title>Import Github Source Code into Eclipse</title><link>http://www.blogjava.net/czihong/articles/391708.html</link><dc:creator>Chan Chen</dc:creator><author>Chan Chen</author><pubDate>Wed, 21 Nov 2012 09:18:00 GMT</pubDate><guid>http://www.blogjava.net/czihong/articles/391708.html</guid><wfw:comment>http://www.blogjava.net/czihong/comments/391708.html</wfw:comment><comments>http://www.blogjava.net/czihong/articles/391708.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/czihong/comments/commentRss/391708.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/czihong/services/trackbacks/391708.html</trackback:ping><description><![CDATA[<div style="font-family: Lato, arial, sans-serif; font-size: 16px; line-height: 24px;">
<p style="margin-left: 10px; margin-right: 10px;"><br />
<br />
Most Eclipse 4.2 packages from Eclipse.org contain EGit in there default configuration. In this case no additional installation is required.</p>
<p style="margin-left: 10px; margin-right: 10px;">If EGit is missing in your Eclipse installation, you can install it via the Eclipse Update Manager via:&nbsp;<span style="font-style: italic;">Help</span>&nbsp;&#8594;<span style="font-style: italic;">Install new Software</span>. EGit can be installed from the following URL: http://download.eclipse.org/egit/updates</p>
<p style="margin-left: 10px; margin-right: 10px;"></p>
<div style="padding: 20px;"><img src="http://www.vogella.com/articles/EGit/images/installation10.png" alt="Installing EGit" style="border-style: none; max-width: 100%;" /></div>
<p style="margin-left: 10px; margin-right: 10px;"></p>
</div>
<div style="font-family: Lato, arial, sans-serif; font-size: 16px; line-height: 24px;">
<div>
<h2><a name="firstegit" style="color: #101010; font-family: Lato, arial, helvetica, sans-serif;"></a>4.&nbsp;The first steps with EGit</h2>
</div>
<p style="margin-left: 10px; margin-right: 10px;">The following section explains how to create a repository for one project and shows how to checkout an exiting projects from a remote repository.</p>
<div>
<div>
<h3>4.1.&nbsp;Put a new project under version control</h3>
</div>
<p style="margin-left: 10px; margin-right: 10px;">Create a new Java project called&nbsp;<em>de.vogella.git.first</em>&nbsp;in Eclipse. Create the&nbsp;<code>de.vogella.git.first</code>package and the following class.</p>
<p style="margin-left: 10px; margin-right: 10px;"></p>
<pre style="background-color: #ffffee; border: 1px solid #bbbbbb; margin: 10px; overflow: auto; padding: 1em; word-wrap: break-word; font-size: 13px; line-height: 16px; font-family: 'Droid Sans Mono', Monaco, 'Bitstream Vera Sans Mono', 'Lucida Console', Terminal, monospace; border-top-left-radius: 9px; border-top-right-radius: 9px; border-bottom-right-radius: 9px; border-bottom-left-radius: 9px;"><span style="color: #7f0055; font-weight: bold;">package</span> de.vogella.git.first; <br /><span style="color: #7f0055; font-weight: bold;">public</span> <span style="color: #7f0055; font-weight: bold;">class</span> GitTest {<br />  <span style="color: #7f0055; font-weight: bold;">public</span> <span style="color: #7f0055; font-weight: bold;">static</span> <span style="color: #7f0055; font-weight: bold;">void</span> main(String[] args) {<br />    System.out.println(<span style="color: blue;">"Git is fun"</span>); <br />  }<br />} </pre>
<p style="margin-left: 10px; margin-right: 10px;"></p>
<p style="margin-left: 10px; margin-right: 10px;">Right click on your project, select&nbsp;<span style="font-style: italic;">Team</span>&nbsp;&#8594;&nbsp;<span style="font-style: italic;">Share Project</span>&nbsp;&#8594;&nbsp;<span style="font-style: italic;">Git</span>. On the next dialog press the&nbsp;<span style="font-style: italic;">Create</span>button.</p>
<p style="margin-left: 10px; margin-right: 10px;"></p>
<div style="padding: 20px;"><img src="http://www.vogella.com/articles/EGit/images/gitfirst10.png" alt="Git repository creation wizard - Step 1" style="border-style: none; max-width: 100%;" /></div>
<p style="margin-left: 10px; margin-right: 10px;"></p>
<p style="margin-left: 10px; margin-right: 10px;">EGit will propose an directory outside your workspace. Enter your project name as&nbsp;<em><code>Name</code></em>&nbsp;for your local Git repository. Select the&nbsp;<span style="font-style: italic;">Finish</span>&nbsp;button.</p>
<p style="margin-left: 10px; margin-right: 10px;"></p>
<div style="padding: 20px;"><img src="http://www.vogella.com/articles/EGit/images/gitfirst20.png" alt="Git repository creation wizard - Step 2" style="border-style: none; max-width: 100%;" /></div>
<p style="margin-left: 10px; margin-right: 10px;"></p>
<p style="margin-left: 10px; margin-right: 10px;">The wizard shows you the settings for your local Git repository. Select the&nbsp;<span style="font-style: italic;">Finish</span>&nbsp;button to put your repository under Git version control.</p>
<p style="margin-left: 10px; margin-right: 10px;"></p>
<div style="padding: 20px;"><img src="http://www.vogella.com/articles/EGit/images/gitfirst30.png" alt="Git repository creation wizard - Step 3" style="border-style: none; max-width: 100%;" /></div>
<p style="margin-left: 10px; margin-right: 10px;"></p>
<p style="margin-left: 10px; margin-right: 10px;">You have created a local Git repository. The git repository is in this case directly stored in the specified folder in a&nbsp;<code style="font-style: italic;">.git</code>&nbsp;folder. The following screenshot shows the directory structure based on the&nbsp;<code>tree -a</code>command.</p>
<p style="margin-left: 10px; margin-right: 10px;"></p>
<div style="padding: 20px;"><img src="http://www.vogella.com/articles/EGit/images/gitfirst40.png" alt="Git repository creation result" style="border-style: none; max-width: 100%;" /></div>
<p style="margin-left: 10px; margin-right: 10px;"></p>
</div>
<div>
<div>
<h3>4.2.&nbsp;Setup Gitignore</h3>
</div>
<p style="margin-left: 10px; margin-right: 10px;">Create a&nbsp;<code style="font-style: italic;">.gitignore&nbsp;</code>file in your project with the following content.</p>
<p style="margin-left: 10px; margin-right: 10px;"></p>
<pre style="background-color: #ffffee; border: 1px solid #bbbbbb; margin: 10px; overflow: auto; padding: 1em; word-wrap: break-word; font-size: 13px; line-height: 16px; font-family: 'Droid Sans Mono', Monaco, 'Bitstream Vera Sans Mono', 'Lucida Console', Terminal, monospace; border-top-left-radius: 9px; border-top-right-radius: 9px; border-bottom-right-radius: 9px; border-bottom-left-radius: 9px;">bin .metadata </pre>
<p style="margin-left: 10px; margin-right: 10px;"></p>
<p style="margin-left: 10px; margin-right: 10px;">All files and directories which apply to the pattern described in this file will be ignored by&nbsp;<em>Git</em>. In this example all files in the&nbsp;<code style="font-style: italic;">bin</code>&nbsp;and the&nbsp;<code style="font-style: italic;">.metadata</code>&nbsp;directory will be ignored.</p>
</div>
<div>
<div>
<h3>4.3.&nbsp;Initial commit</h3>
</div>
<p style="margin-left: 10px; margin-right: 10px;">The&nbsp;<span style="font-style: italic;">Git Staging</span>&nbsp;<em>View</em>&nbsp;allows to stage changes and to commit them.</p>
<p style="margin-left: 10px; margin-right: 10px;">Open the&nbsp;<span style="font-style: italic;">Git Staging</span>&nbsp;<em>View</em>&nbsp;via the menu&nbsp;<span style="font-style: italic;">Window</span>&nbsp;&#8594;&nbsp;<span style="font-style: italic;">Show View</span>&nbsp;&#8594;&nbsp;<span style="font-style: italic;">Other</span>&nbsp;&#8594;&nbsp;<span style="font-style: italic;">Git</span>&nbsp;&#8594;&nbsp;<span style="font-style: italic;">Git Staging</span>.</p>
<p style="margin-left: 10px; margin-right: 10px;">Mark all files which have changed on drag them into the&nbsp;<span style="font-style: italic;">Staged Changes</span>&nbsp;area.</p>
<p style="margin-left: 10px; margin-right: 10px;"></p>
<div style="padding: 20px;"><img src="http://www.vogella.com/articles/EGit/images/gitstaging10.png" alt="Git Staging View - Add to staging index" style="border-style: none; max-width: 100%;" /></div>
<p style="margin-left: 10px; margin-right: 10px;"></p>
<p style="margin-left: 10px; margin-right: 10px;">Write a descriptive commmit message and press the&nbsp;<span style="font-style: italic;">Commit</span>&nbsp;button which is hightlighted in the following screenshot.</p>
<p style="margin-left: 10px; margin-right: 10px;"></p>
<div style="padding: 20px;"><img src="http://www.vogella.com/articles/EGit/images/gitstaging20.png" alt="Git Staging View - Commit" style="border-style: none; max-width: 100%;" /></div>
<p style="margin-left: 10px; margin-right: 10px;"></p>
<p style="margin-left: 10px; margin-right: 10px;">Now the first version of your Java project is under version control.</p>
</div>
<div>
<div>
<h3>4.4.&nbsp;Making changes and commiting them</h3>
</div>
<p style="margin-left: 10px; margin-right: 10px;">Change the&nbsp;<code>System.out.println</code>&nbsp;message in your&nbsp;<code>GitTest</code>&nbsp;class.</p>
<p style="margin-left: 10px; margin-right: 10px;"></p>
<pre style="background-color: #ffffee; border: 1px solid #bbbbbb; margin: 10px; overflow: auto; padding: 1em; word-wrap: break-word; font-size: 13px; line-height: 16px; font-family: 'Droid Sans Mono', Monaco, 'Bitstream Vera Sans Mono', 'Lucida Console', Terminal, monospace; border-top-left-radius: 9px; border-top-right-radius: 9px; border-bottom-right-radius: 9px; border-bottom-left-radius: 9px;"><span style="color: #7f0055; font-weight: bold;">package</span> de.vogella.git.first; <br /><span style="color: #7f0055; font-weight: bold;">public</span> <span style="color: #7f0055; font-weight: bold;">class</span> GitTest { <br /><span style="color: #7f0055; font-weight: bold;">  public</span> <span style="color: #7f0055; font-weight: bold;">static</span> <span style="color: #7f0055; font-weight: bold;">void</span> main(String[] args) { <br />    System.out.println(<span style="color: blue;">"Git is cool"</span>); <br />  }<br />} </pre>
<p style="margin-left: 10px; margin-right: 10px;"></p>
<p style="margin-left: 10px; margin-right: 10px;">Drag the file which you have changed into the&nbsp;<span style="font-style: italic;">Staged Changes</span>&nbsp;area, write a good commit message and press the commit button.</p>
<p style="margin-left: 10px; margin-right: 10px;"></p>
<div style="padding: 20px;"><img src="http://www.vogella.com/articles/EGit/images/gitstaging30.png" alt="Git Staging View - Add to staging index" style="border-style: none; max-width: 100%;" /></div>
<p style="margin-left: 10px; margin-right: 10px;"></p>
<p style="margin-left: 10px; margin-right: 10px;">This change will now be in your local&nbsp;<em>Git</em>&nbsp;repository.</p>
</div>
<div>
<div>
<h3>4.5.&nbsp;Show changes</h3>
</div>
<p style="margin-left: 10px; margin-right: 10px;">Open the Git repository view via the following menu entries:&nbsp;<span style="font-style: italic;">Window</span>&nbsp;&#8594;&nbsp;<span style="font-style: italic;">Show View</span>&nbsp;&#8594;&nbsp;<span style="font-style: italic;">Other</span>&nbsp;&#8594;&nbsp;<span style="font-style: italic;">Git</span>&nbsp;&#8594;&nbsp;<span style="font-style: italic;">Git Staging</span>.</p>
<p style="margin-left: 10px; margin-right: 10px;">Select your project, right click on it and select&nbsp;<span style="font-style: italic;">Show in&nbsp;</span>&#8594;&nbsp;<span style="font-style: italic;">History</span>&nbsp;to see the timeline of changes.</p>
<p style="margin-left: 10px; margin-right: 10px;">If you select a commit you see the commit message and the involved files.</p>
<p style="margin-left: 10px; margin-right: 10px;"></p>
<div style="padding: 20px;"><img src="http://www.vogella.com/articles/EGit/images/githistoryview10.png" alt="History View" style="border-style: none; max-width: 100%;" /></div>
<p style="margin-left: 10px; margin-right: 10px;"></p>
<p style="margin-left: 10px; margin-right: 10px;">Via right mouse click on an individual file you can compare this file with its ancestor (the commit before that) or with the current version in the workspace.</p>
</div>
</div>
<div style="font-family: Lato, arial, sans-serif; font-size: 16px; line-height: 24px;">
<div>
<h2>5.&nbsp;Commit messages</h2>
</div>
<div>
<div>
<h3>5.1.&nbsp;Importance of Git commit messages</h3>
</div>
<p style="margin-left: 10px; margin-right: 10px;">The commit message describes the changes done by a commit and is used as the first point of checking the history of a Git repository.</p>
<p style="margin-left: 10px; margin-right: 10px;">A commit message should therefore be descriptive and informative without repeating the code changes.</p>
</div>
<div>
<div>
<h3>5.2.&nbsp;Guidelines for useful commit messages</h3>
</div>
<p style="margin-left: 10px; margin-right: 10px;">A commit message should have a header and a body. The header should be less than 50 characters and the body should wrap its text at 72 so that the commit messages is displayed well on the command line. The body should be separated by the header with an empty line.</p>
<p style="margin-left: 10px; margin-right: 10px;">The body should contain the reason why the change was made.</p>
<p style="margin-left: 10px; margin-right: 10px;">The commit message should be in present tense, e.g. "Add better error handling" instead of "Added better error handling".</p>
</div>
<div>
<div>
<h3>5.3.&nbsp;Example</h3>
</div>
<p style="margin-left: 10px; margin-right: 10px;">The following can serve as an example for a commit message.</p>
<p style="margin-left: 10px; margin-right: 10px;"></p>
<pre style="background-color: #ffffee; border: 1px solid #bbbbbb; margin: 10px; overflow: auto; padding: 1em; word-wrap: break-word; font-size: 13px; line-height: 16px; font-family: 'Droid Sans Mono', Monaco, 'Bitstream Vera Sans Mono', 'Lucida Console', Terminal, monospace; border-top-left-radius: 9px; border-top-right-radius: 9px; border-bottom-right-radius: 9px; border-bottom-left-radius: 9px;">Short summary (less than 50 characters) Detailed explanation, <span style="color: #7f0055; font-weight: bold;">if</span> required, line <span style="color: #7f0055; font-weight: bold;">break</span> at around 72 characters more stuff to describe... </pre>
<p style="margin-left: 10px; margin-right: 10px;"></p>
</div>
</div>
<div style="font-family: Lato, arial, sans-serif; font-size: 16px; line-height: 24px;">
<div>
<h2>6.&nbsp;Repository view</h2>
</div>
<p style="margin-left: 10px; margin-right: 10px;">EGit has a&nbsp;<span style="font-style: italic;">Git repository</span>&nbsp;view which allow you to browse your repositories, checkout projects and manage your branches.</p>
<p style="margin-left: 10px; margin-right: 10px;"></p>
<div style="padding: 20px;"><img src="http://www.vogella.com/articles/EGit/images/repositoryview10.gif" style="border-style: none; max-width: 100%;" alt="" /></div>
<p style="margin-left: 10px; margin-right: 10px;"></p>
</div>
<div style="font-family: Lato, arial, sans-serif; font-size: 16px; line-height: 24px;">
<div>
<h2>7.&nbsp;Clone existing project</h2>
</div>
<p style="margin-left: 10px; margin-right: 10px;"><em>EGit</em>&nbsp;allows to clone an existing Git repository.</p>
<p style="margin-left: 10px; margin-right: 10px;">Select&nbsp;<span style="font-style: italic;">File</span>&nbsp;&#8594;&nbsp;<span style="font-style: italic;">Import</span>&nbsp;&#8594;&nbsp;<span style="font-style: italic;">Git</span>&nbsp;&#8594;&nbsp;<span style="font-style: italic;">Project from Git</span>.</p>
<p style="margin-left: 10px; margin-right: 10px;"></p>
<div style="padding: 20px;"><img src="http://www.vogella.com/articles/EGit/images/egit_import08.png" alt="Importing projects via EGit" style="border-style: none; max-width: 100%;" /></div>
<p style="margin-left: 10px; margin-right: 10px;"></p>
<p style="margin-left: 10px; margin-right: 10px;">Select&nbsp;<span style="font-style: italic;">URI</span>&nbsp;in the next dialog.</p>
<p style="margin-left: 10px; margin-right: 10px;"></p>
<div style="padding: 20px;"><img src="http://www.vogella.com/articles/EGit/images/egit_import09.png" alt="URI selected in EGit" style="border-style: none; max-width: 100%;" /></div>
<p style="margin-left: 10px; margin-right: 10px;"></p>
<p style="margin-left: 10px; margin-right: 10px;">Press clone and enter the URL to your Git repository. Git supports several protocols, e.g.&nbsp;<em><code>git://</code></em>&nbsp;and<em><code>https://</code></em>. You only have to paste the URL to the first line of the dialog, the rest will be filled out automatically.</p>
<p style="margin-left: 10px; margin-right: 10px;">Please note that some proxy servers block the&nbsp;<em><code>git://</code></em>&nbsp;protocol. If you face issues, please try to use the<em><code>https://</code></em>&nbsp;protocol.</p>
<p style="margin-left: 10px; margin-right: 10px;">For example the following URI can be used to clone the example projects of the Eclipse 4 application development book: git@github.com:vogella/eclipse4book.git</p>
<p style="margin-left: 10px; margin-right: 10px;"></p>
<div style="padding: 20px;"><img src="http://www.vogella.com/articles/EGit/images/egit_import10.png" alt="URI entered in the dialog" style="border-style: none; max-width: 100%;" /></div>
<p style="margin-left: 10px; margin-right: 10px;"></p>
<p style="margin-left: 10px; margin-right: 10px;">After pressing next the system will allow you to import the existing branches. You should select at least<span style="font-style: italic;">master</span>&nbsp;as this is typically the main development branch.</p>
<p style="margin-left: 10px; margin-right: 10px;"></p>
<div style="padding: 20px;"><img src="http://www.vogella.com/articles/EGit/images/egit_import20.png" alt="URI entered in the dialog" style="border-style: none; max-width: 100%;" /></div>
<p style="margin-left: 10px; margin-right: 10px;"></p>
<p style="margin-left: 10px; margin-right: 10px;">The next dialog allows you to specify where the project should be copied to and which branch should be initially selected.</p>
<p style="margin-left: 10px; margin-right: 10px;"></p>
<div style="padding: 20px;"><img src="http://www.vogella.com/articles/EGit/images/egit_import30.png" alt="Define target directory for Git repository" style="border-style: none; max-width: 100%;" /></div>
<p style="margin-left: 10px; margin-right: 10px;"></p>
<p style="margin-left: 10px; margin-right: 10px;">After the Git repository is cloned,&nbsp;<em>EGit</em>&nbsp;opens an additional import dialog which allows to import the Eclipse projects from the Git repository.</p>
<p style="margin-left: 10px; margin-right: 10px;"></p>
<div style="padding: 20px;"><img src="http://www.vogella.com/articles/EGit/images/egit_import40.png" alt="Importing projects" style="border-style: none; max-width: 100%;" /></div>
<p style="margin-left: 10px; margin-right: 10px;"></p>
<p style="margin-left: 10px; margin-right: 10px;">Once this dialog is completed, you have checked out (cloned) the projects into a local Git repository and you can use Git operation on these projects.</p>
</div>
<iframe allowtransparency="true" frameborder="0" height="90" hspace="0" marginwidth="0" marginheight="0" scrolling="no" vspace="0" width="728" id="aswift_1" name="aswift_1" style="left: 0px; position: absolute; top: 0px;"></iframe>
<div style="font-family: Lato, arial, sans-serif; font-size: 16px; line-height: 24px;">
<div>
<h2>8.&nbsp;Using EGit</h2>
</div>
<div>
<div>
<h3>8.1.&nbsp;Basic operations</h3>
</div>
<p style="margin-left: 10px; margin-right: 10px;">Once you have placed a project under version control you can start using team operations on your project. The team operations are available via right mouse click on your project. You can:</p>
<div>
<ul type="disc">
     <li>
     <p style="margin-left: 10px; margin-right: 10px;">Select&nbsp;<span style="font-style: italic;">Team</span>&nbsp;&#8594;&nbsp;<span style="font-style: italic;">Add</span>, on the project node to add all files to version control.</p>
     </li>
     <li>
     <p style="margin-left: 10px; margin-right: 10px;">Select "Team" -&gt; "Commit", to commit your changes to the local Git repository.</p>
     </li>
     <li>
     <p style="margin-left: 10px; margin-right: 10px;">Select "Team" -&gt; "Push" to push your change to a remote Git repository (see the GitHub chapter).</p>
     </li>
     <li>
     <p style="margin-left: 10px; margin-right: 10px;">"Team" -&gt; "Tag" allows you to create and manage tags.</p>
     </li>
</ul>
</div>
<p style="margin-left: 10px; margin-right: 10px;"></p>
</div>
<div>
<div>
<h3>8.2.&nbsp;Merge</h3>
</div>
<p style="margin-left: 10px; margin-right: 10px;">EGit supports merging of branches to add the changes of one branch into another if this branch has not been changed. Select your project and&nbsp;<span style="font-style: italic;">Team</span>&nbsp;&#8594;&nbsp;<span style="font-style: italic;">Merge</span>&nbsp;to start the merge dialog.</p>
</div>
<div>
<div>
<h3>8.3.&nbsp;Solving Merge Conflicts</h3>
</div>
<p style="margin-left: 10px; margin-right: 10px;">If you pull in changes or merge a branch and you have conflicting changes, EGit will highlight the affected files. EGit also supports the resolution of these merge conflicts.</p>
<p style="margin-left: 10px; margin-right: 10px;">Right click on a file with merge conflicts and select&nbsp;<span style="font-style: italic;">Team</span>&nbsp;&#8594;&nbsp;<span style="font-style: italic;">Merge Tool</span>.</p>
<p style="margin-left: 10px; margin-right: 10px;">This opens a dialog, asking you which merge mode you would like to use. The easiest way to see the conflicting changes is to use the&nbsp;<span style="font-style: italic;">Use HEAD (the last local version) of conflicting files&nbsp;</span>as merge mode. This way you see the original changes on the left side and the conflicting changes on the right side.</p>
<p style="margin-left: 10px; margin-right: 10px;"></p>
<div style="padding: 20px;"><img src="http://www.vogella.com/articles/EGit/images/egitmerge08.png" alt="Selecting the merge model" style="border-style: none; max-width: 100%;" /></div>
<p style="margin-left: 10px; margin-right: 10px;"></p>
<p style="margin-left: 10px; margin-right: 10px;">You can manually edit the text on the left side or use the&nbsp;<span style="font-style: italic;">Copy current change from right to left</span>&nbsp;button to copy the conflicting changes from right to left.</p>
<p style="margin-left: 10px; margin-right: 10px;"></p>
<div style="padding: 20px;"><img src="http://www.vogella.com/articles/EGit/images/egitmerge10.png" alt="Seeing merge conflicts" style="border-style: none; max-width: 100%;" /></div>
<p style="margin-left: 10px; margin-right: 10px;"></p>
<p style="margin-left: 10px; margin-right: 10px;"></p>
<div style="padding: 20px;"><img src="http://www.vogella.com/articles/EGit/images/egitmerge20.png" alt="Copy changes from right to left" style="border-style: none; max-width: 100%;" /></div>
<p style="margin-left: 10px; margin-right: 10px;"></p>
<p style="margin-left: 10px; margin-right: 10px;">Once you have manually merged the changes, select&nbsp;<span style="font-style: italic;">Team</span>&nbsp;&#8594;&nbsp;<span style="font-style: italic;">Add</span>&nbsp;from the context menu of the resource to mark the conflicts as resolved and commit the merge resolution via&nbsp;<span style="font-style: italic;">Team</span>&nbsp;&#8594;&nbsp;<span style="font-style: italic;">Commit</span>.</p>
</div>
<div>
<div>
<h3>8.4.&nbsp;Git amend</h3>
</div>
<p style="margin-left: 10px; margin-right: 10px;">Git amend allows to adjust the last commit. For example you can change the commit message. The Git Staging view allows to perform the Git amend command via the the highlighted button in the following screenshot.</p>
<p style="margin-left: 10px; margin-right: 10px;"></p>
<div style="padding: 20px;"><img src="http://www.vogella.com/articles/EGit/images/egitamend10.png" alt="Git amend in the Git Staging view" style="border-style: none; max-width: 100%;" />8.5.&nbsp;View the resource history</div></div><div>
<p style="margin-left: 10px; margin-right: 10px;">Select a resource and select Show in (Alt+Shift+W) -&gt; History to see the commit history of this resource.</p>
<p style="margin-left: 10px; margin-right: 10px;"></p>
<div style="padding: 20px;"><img src="http://www.vogella.com/articles/EGit/images/history10.gif" style="border-style: none; max-width: 100%;" alt="" /></div>
<p style="margin-left: 10px; margin-right: 10px;"></p>
<p style="margin-left: 10px; margin-right: 10px;"></p>
<div style="padding: 20px;"><img src="http://www.vogella.com/articles/EGit/images/history20.gif" style="border-style: none; max-width: 100%;" alt="" /></div>
<p style="margin-left: 10px; margin-right: 10px;"></p>
</div>
</div>
<div style="font-family: Lato, arial, sans-serif; font-size: 16px; line-height: 24px;">
<div>
<h2>9.&nbsp;Branching</h2>
</div>
<div>
<div>
<h3>9.1.&nbsp;What are branches?</h3>
</div>
<p style="margin-left: 10px; margin-right: 10px;">Git allows you to create&nbsp;<em>branches</em>, e.g. independent copies of the source code which can be changed independently from each other. The default branch is called&nbsp;<em>master</em>.</p>
<p style="margin-left: 10px; margin-right: 10px;">Git allows you to create branches very fast and cheaply in terms of resource consumption. Developers are encouraged to use branches frequently.</p>
</div>
<div>
<div>
<h3>9.2.&nbsp;Switch Branches</h3>
</div>
<p style="margin-left: 10px; margin-right: 10px;">Right-click your project and select&nbsp;<span style="font-style: italic;">Team</span>&nbsp;&#8594;&nbsp;<span style="font-style: italic;">Branch</span>&nbsp;to create new branches or to switch between existing branches.</p>
</div>
</div>
<div style="font-family: Lato, arial, sans-serif; font-size: 16px; line-height: 24px;">
<div>
<h2>10.&nbsp;Git repository for multiple projects</h2>
</div>
<div>
<div>
<h3>10.1.&nbsp;Create a new repository</h3>
</div>
<p style="margin-left: 10px; margin-right: 10px;">Eclipse allows to work with projects which are not included in the workspace.</p>
<p style="margin-left: 10px; margin-right: 10px;">To put several Eclipse projects into the same Git repository you can create a folder inside or outside your workspace and create the projects inside this folder. You can create a Git repository for this folder and all projects in this folder will be handled by the same repository. The best practice is to put the Git repository outsite of the Eclipse workspace.</p>
<p style="margin-left: 10px; margin-right: 10px;">You can import these projects into your workspace via&nbsp;<span style="font-style: italic;">File</span>&nbsp;&#8594;&nbsp;<span style="font-style: italic;">Import</span>&nbsp;&#8594;&nbsp;<span style="font-style: italic;">Git</span>&nbsp;&#8594;&nbsp;<span style="font-style: italic;">Projects from Git</span></p>
<p style="margin-left: 10px; margin-right: 10px;"></p>
<div style="padding: 20px;"><img src="http://www.vogella.com/articles/EGit/images/importprojectsgit10.png" alt="Import project from Git repository" style="border-style: none; max-width: 100%;" /></div>
<p style="margin-left: 10px; margin-right: 10px;"></p>
</div>
<div>
<div>
<h3>10.2.&nbsp;Add a project to an existing Git repository</h3>
</div>
<p style="margin-left: 10px; margin-right: 10px;">To add a new Eclipse project to an existing Git repository, select the project, right click on it and select<span style="font-style: italic;">Team</span>&nbsp;&#8594;&nbsp;<span style="font-style: italic;">Share</span>&nbsp;&#8594;&nbsp;<span style="font-style: italic;">Git</span>&nbsp;and select the existing Git repository.</p>
<p style="margin-left: 10px; margin-right: 10px;"></p>
<div style="padding: 20px;"><img src="http://www.vogella.com/articles/EGit/images/addprojecttogitrepo10.png" alt="Adding a project to an existing Git repository" style="border-style: none; max-width: 100%;" /></div>
<p style="margin-left: 10px; margin-right: 10px;"></p>
<p style="margin-left: 10px; margin-right: 10px;">EGit moves the projects to the repository and imports the project automatically into your workspace.</p>
</div>
</div>
<div style="font-family: Lato, arial, sans-serif; font-size: 16px; line-height: 24px;">
<div>
<h2>11.&nbsp;Tutorial: Create Git repository for multiple projects</h2>
</div>
<p style="margin-left: 10px; margin-right: 10px;">Create two Java projects called&nbsp;<em>de.vogella.egit.multi.java1</em>&nbsp;and&nbsp;<em>de.vogella.egit.multi.java2</em>. Do not use the default location (which would be the workspace) but use a subfolder called&nbsp;<code style="font-style: italic;">gitmulti</code>.</p>
<p style="margin-left: 10px; margin-right: 10px;"></p>
<div style="padding: 20px;"><img src="http://www.vogella.com/articles/EGit/images/multi10.png" style="border-style: none; max-width: 100%;" alt="" /></div>
<p style="margin-left: 10px; margin-right: 10px;"></p>
<p style="margin-left: 10px; margin-right: 10px;"></p>
<div style="padding: 20px;"><img src="http://www.vogella.com/articles/EGit/images/multi20.png" style="border-style: none; max-width: 100%;" alt="" /></div>
<p style="margin-left: 10px; margin-right: 10px;"></p>
<p style="margin-left: 10px; margin-right: 10px;">Create at least on Java class in each project. Git is not able to save empty folders.</p>
<p style="margin-left: 10px; margin-right: 10px;">Afterwards select both projects, right click on them and select&nbsp;<span style="font-style: italic;">Team</span>&nbsp;&#8594;&nbsp;<span style="font-style: italic;">Share</span>&nbsp;&#8594;&nbsp;<span style="font-style: italic;">Git</span>.</p>
<p style="margin-left: 10px; margin-right: 10px;"></p>
<div style="padding: 20px;"><img src="http://www.vogella.com/articles/EGit/images/multi30.png" style="border-style: none; max-width: 100%;" alt="" /></div>
<p style="margin-left: 10px; margin-right: 10px;"></p>
<p style="margin-left: 10px; margin-right: 10px;">You create a new Git repository which contains both projects.</p>
<p style="margin-left: 10px; margin-right: 10px;"></p>
<div style="padding: 20px;"><img src="http://www.vogella.com/articles/EGit/images/multi40.png" style="border-style: none; max-width: 100%;" alt="" /></div>
<p style="margin-left: 10px; margin-right: 10px;"></p>
</div>
<div lqm_publisher="lqm.javaeclipseandroid.site" lqm_tags="Java%20Mobile%20Android" lqm_zone="ron" lqm_format="728x90" style="font-family: Lato, arial, sans-serif; font-size: 16px; line-height: 24px;"><iframe id="lqmad2" width="728" height="90" marginwidth="0" marginheight="0" frameborder="0" scrolling="no"></iframe></div>
<div style="font-family: Lato, arial, sans-serif; font-size: 16px; line-height: 24px;">
<div>
<h2>12.&nbsp;Using EGit with Github</h2>
</div>
<div>
<div>
<h3><a name="github_overview" style="color: #101010; font-family: Lato, arial, helvetica, sans-serif;"></a>12.1.&nbsp;Github</h3>
</div>
<p style="margin-left: 10px; margin-right: 10px;"><a href="https://github.com/" target="_top" style="color: #101010; font-family: Lato, arial, helvetica, sans-serif; font-weight: 700;">Github&nbsp;</a>is a popular hosting provider for Git projects and if you repository is public to everyone Github hosting is free. To use GitHub create an account on the&nbsp;<a href="https://github.com/" target="_top" style="color: #101010; font-family: Lato, arial, helvetica, sans-serif; font-weight: 700;">Github Website</a>. During the sign-up you will be asked to provide a "passphase". This "passphase" is later needed to push to Github from your local repository.</p>
</div>
<div>
<div>
<h3>12.2.&nbsp;Create Repository in Github</h3>
</div>
<p style="margin-left: 10px; margin-right: 10px;">Create a new repository on Github, e.g. "de.vogella.git.github".</p>
<p style="margin-left: 10px; margin-right: 10px;"></p>
<div style="padding: 20px;"><img src="http://www.vogella.com/articles/EGit/images/github20.gif" style="border-style: none; max-width: 100%;" alt="" /></div>
<p style="margin-left: 10px; margin-right: 10px;"></p>
<p style="margin-left: 10px; margin-right: 10px;">After creation of your new repository Github tells you what to do if you would inport via the command line. As we are going to use EGit we can ignore this information.</p>
</div>
<div>
<div>
<h3>12.3.&nbsp;Push project to Github</h3>
</div>
<p style="margin-left: 10px; margin-right: 10px;">Create a new project "de.vogella.git.github" and put it under version control. Right-mouse click on your project and select "Team" -&gt; "Push". A dialog pops up. Maintain the following data. Adjust the hightlighted line so that you are using your user and your project name.</p>
<p style="margin-left: 10px; margin-right: 10px;"></p>
<pre style="background-color: #ffffee; border: 1px solid #bbbbbb; margin: 10px; overflow: auto; padding: 1em; word-wrap: break-word; font-size: 13px; line-height: 16px; font-family: 'Droid Sans Mono', Monaco, 'Bitstream Vera Sans Mono', 'Lucida Console', Terminal, monospace; border-top-left-radius: 9px; border-top-right-radius: 9px; border-bottom-right-radius: 9px; border-bottom-left-radius: 9px;">git+ssh:<em style="color: #008800;">//git@github.com/vogella/de.vogella.git.github </em></pre>
<div style="padding: 20px;"><img src="http://www.vogella.com/articles/EGit/images/github40.gif" style="border-style: none; max-width: 100%;" alt="" /></div>
<p style="margin-left: 10px; margin-right: 10px;">Maintain your passphase which you maintained during the Github setup.</p>
<p style="margin-left: 10px; margin-right: 10px;"></p>
<div style="padding: 20px;"><img src="http://www.vogella.com/articles/EGit/images/github50.gif" style="border-style: none; max-width: 100%;" alt="" /></div>
<p style="margin-left: 10px; margin-right: 10px;"></p>
<p style="margin-left: 10px; margin-right: 10px;">Select your branch (you should currently only have master if you followed my tutorial), press "Add all branches spec" and select next.</p>
<p style="margin-left: 10px; margin-right: 10px;"></p>
<div style="padding: 20px;"><img src="http://www.vogella.com/articles/EGit/images/github60.gif" style="border-style: none; max-width: 100%;" alt="" /></div>
<p style="margin-left: 10px; margin-right: 10px;"></p>
<p style="margin-left: 10px; margin-right: 10px;">Press finish.</p>
<p style="margin-left: 10px; margin-right: 10px;"></p>
<div style="padding: 20px;"><img src="http://www.vogella.com/articles/EGit/images/github70.gif" style="border-style: none; max-width: 100%;" alt="" /></div>
<p style="margin-left: 10px; margin-right: 10px;"></p>
<p style="margin-left: 10px; margin-right: 10px;">If you now select your github Dashboard and then your project you should see the commited files.</p>
<p style="margin-left: 10px; margin-right: 10px;"></p>
<div style="padding: 20px;"><img src="http://www.vogella.com/articles/EGit/images/github80.gif" style="border-style: none; max-width: 100%;" alt="" /></div>
<p style="margin-left: 10px; margin-right: 10px;"></p>
</div>
<div>
<div>
<h3>12.4.&nbsp;Clone repository from Github</h3>
</div>
<p style="margin-left: 10px; margin-right: 10px;">Use the same URI you use to push to Github to clone the project into another workspace.</p>
</div>
</div>
<div style="font-family: Lato, arial, sans-serif; font-size: 16px; line-height: 24px;">
<div>
<h2>13.&nbsp;Mylyn integration with Github</h2>
</div>
<a href="http://www.vogella.com/articles//Mylyn/article.html" target="_top" style="color: #101010; font-family: Lato, arial, helvetica, sans-serif; font-weight: 700;">Eclipse Mylyn&nbsp;</a>is a productively tool for programmers. There is a GitHub connector for Mylyn available, please see&nbsp;<a href="http://wiki.eclipse.org/EGit/GitHub/UserGuide" target="_top" style="color: #101010; font-family: Lato, arial, helvetica, sans-serif; font-weight: 700;">http://wiki.eclipse.org/EGit/GitHub/UserGuide&nbsp;</a>for details. .</div>
<div style="font-family: Lato, arial, sans-serif; font-size: 16px; line-height: 24px;">
<div>
<h2>14.&nbsp;Hacking EGit - Getting the source code</h2>
</div>
<p style="margin-left: 10px; margin-right: 10px;">EGit is self-hosted on&nbsp;<a href="git://egit.eclipse.org" target="_top" style="color: #101010; font-family: Lato, arial, helvetica, sans-serif; font-weight: 700;">git://egit.eclipse.org</a>. You can clone the EGit code from the repository using EGit using the following URL&nbsp;<a href="git://egit.eclipse.org/jgit.git" target="_top" style="color: #101010; font-family: Lato, arial, helvetica, sans-serif; font-weight: 700;">git://egit.eclipse.org/jgit.git</a>&nbsp;and&nbsp;<a href="git://egit.eclipse.org/egit.git" target="_top" style="color: #101010; font-family: Lato, arial, helvetica, sans-serif; font-weight: 700;">git://egit.eclipse.org/egit.git</a>.</p>
<p style="margin-left: 10px; margin-right: 10px;">You also need some libraries from Orbit. See&nbsp;<a href="http://wiki.eclipse.org/EGit/Contributor_Guide#Libraries_from_Orbit" target="_top" style="color: #101010; font-family: Lato, arial, helvetica, sans-serif; font-weight: 700;">Libraries from Orbit</a>&nbsp;for getting these libraries.</p>
</div><img src ="http://www.blogjava.net/czihong/aggbug/391708.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/czihong/" target="_blank">Chan Chen</a> 2012-11-21 17:18 <a href="http://www.blogjava.net/czihong/articles/391708.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Git Tag Release</title><link>http://www.blogjava.net/czihong/articles/374054.html</link><dc:creator>Chan Chen</dc:creator><author>Chan Chen</author><pubDate>Fri, 13 Apr 2012 03:43:00 GMT</pubDate><guid>http://www.blogjava.net/czihong/articles/374054.html</guid><wfw:comment>http://www.blogjava.net/czihong/comments/374054.html</wfw:comment><comments>http://www.blogjava.net/czihong/articles/374054.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/czihong/comments/commentRss/374054.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/czihong/services/trackbacks/374054.html</trackback:ping><description><![CDATA[<p style="margin: 0px 0px 1em; padding: 0px; border: 0px; vertical-align: baseline; background-color: #ffffff; clear: both; word-wrap: break-word; font-family: Arial, 'Liberation Sans', 'DejaVu Sans', sans-serif; line-height: 18px; text-align: left; "><em style="margin: 0px; padding: 0px; border: 0px; vertical-align: baseline; background-color: transparent; ">How do you 'mark' 'tag' or 'release' a particular set of revisions for a particular set of files so you can always pull that one later?</em></p><p style="margin: 0px 0px 1em; padding: 0px; border: 0px; vertical-align: baseline; background-color: #ffffff; clear: both; word-wrap: break-word; font-family: Arial, 'Liberation Sans', 'DejaVu Sans', sans-serif; line-height: 18px; text-align: left; ">Using the&nbsp;<code style="margin: 0px; padding: 1px 5px; border: 0px; vertical-align: baseline; background-color: #eeeeee; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, serif; ">git tag</code>&nbsp;command.</p><p style="margin: 0px 0px 1em; padding: 0px; border: 0px; vertical-align: baseline; background-color: #ffffff; clear: both; word-wrap: break-word; font-family: Arial, 'Liberation Sans', 'DejaVu Sans', sans-serif; line-height: 18px; text-align: left; ">To simply "tag" the current revision, you would just run..</p><pre style="margin-top: 0px; margin-bottom: 10px; padding: 5px; border: 0px; vertical-align: baseline; background-color: #eeeeee; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, serif; overflow: auto; width: auto; max-height: 600px; line-height: 18px; text-align: left; "><code style="margin: 0px; padding: 0px; border: 0px; vertical-align: baseline; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, serif; ">git tag -a thetagname <br />git tag -a 0.1 <br />git tag -a 2.6.1-rc1 -m 'Released on 01/02/03' </code></pre><p style="margin: 0px 0px 1em; padding: 0px; border: 0px; vertical-align: baseline; background-color: #ffffff; clear: both; word-wrap: break-word; font-family: Arial, 'Liberation Sans', 'DejaVu Sans', sans-serif; line-height: 18px; text-align: left; ">To list the current tags, simply run&nbsp;<code style="margin: 0px; padding: 1px 5px; border: 0px; vertical-align: baseline; background-color: #eeeeee; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, serif; ">git tag</code>&nbsp;with no arguments, or&nbsp;<code style="margin: 0px; padding: 1px 5px; border: 0px; vertical-align: baseline; background-color: #eeeeee; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, serif; ">-l</code>&nbsp;(lower case L):</p><pre style="margin-top: 0px; margin-bottom: 10px; padding: 5px; border: 0px; vertical-align: baseline; background-color: #eeeeee; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, serif; overflow: auto; width: auto; max-height: 600px; line-height: 18px; text-align: left; "><code style="margin: 0px; padding: 0px; border: 0px; vertical-align: baseline; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, serif; ">$ git tag -a thetagname # and enter a message, or use -m 'My tag annotation' <br />$ git tag -l thetagname </code></pre><p style="margin: 0px 0px 1em; padding: 0px; border: 0px; vertical-align: baseline; background-color: #ffffff; clear: both; word-wrap: break-word; font-family: Arial, 'Liberation Sans', 'DejaVu Sans', sans-serif; line-height: 18px; text-align: left; ">To delete a tag, you use the&nbsp;<code style="margin: 0px; padding: 1px 5px; border: 0px; vertical-align: baseline; background-color: #eeeeee; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, serif; ">-d</code>&nbsp;flag:</p><pre style="margin-top: 0px; margin-bottom: 10px; padding: 5px; border: 0px; vertical-align: baseline; background-color: #eeeeee; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, serif; overflow: auto; width: auto; max-height: 600px; line-height: 18px; text-align: left; "><code style="margin: 0px; padding: 0px; border: 0px; vertical-align: baseline; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, serif; ">$ git tag -d thetagname  Deleted tag 'thetagname' <br />$ git tag [no output] </code></pre><p style="margin: 0px 0px 1em; padding: 0px; border: 0px; vertical-align: baseline; background-color: #ffffff; clear: both; word-wrap: break-word; font-family: Arial, 'Liberation Sans', 'DejaVu Sans', sans-serif; line-height: 18px; text-align: left; ">To tag a specific (previous) commit, you simply do..</p><pre style="margin-top: 0px; margin-bottom: 10px; padding: 5px; border: 0px; vertical-align: baseline; background-color: #eeeeee; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, serif; overflow: auto; width: auto; max-height: 600px; line-height: 18px; text-align: left; "><code style="margin: 0px; padding: 0px; border: 0px; vertical-align: baseline; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, serif; ">git tag [tag name] [revision SHA1 hash] </code></pre><p style="margin: 0px 0px 1em; padding: 0px; border: 0px; vertical-align: baseline; background-color: #ffffff; clear: both; word-wrap: break-word; font-family: Arial, 'Liberation Sans', 'DejaVu Sans', sans-serif; line-height: 18px; text-align: left; ">For example:</p><pre style="margin-top: 0px; margin-bottom: 10px; padding: 5px; border: 0px; vertical-align: baseline; background-color: #eeeeee; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, serif; overflow: auto; width: auto; max-height: 600px; line-height: 18px; text-align: left; "><code style="margin: 0px; padding: 0px; border: 0px; vertical-align: baseline; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, serif; ">git tag 1.1.1 81b15a68c6c3e71f72e766931df4e6499990385b </code></pre><p style="margin: 0px 0px 1em; padding: 0px; border: 0px; vertical-align: baseline; background-color: #ffffff; clear: both; word-wrap: break-word; font-family: Arial, 'Liberation Sans', 'DejaVu Sans', sans-serif; line-height: 18px; text-align: left; "></p><hr style="border: 0px; color: #dddddd; background-color: #dddddd; height: 1px; margin-bottom: 20px; font-family: Arial, 'Liberation Sans', 'DejaVu Sans', sans-serif; line-height: 18px; text-align: left; " /><p style="margin: 0px 0px 1em; padding: 0px; border: 0px; vertical-align: baseline; background-color: #ffffff; clear: both; word-wrap: break-word; font-family: Arial, 'Liberation Sans', 'DejaVu Sans', sans-serif; line-height: 18px; text-align: left; "></p><p style="margin: 0px 0px 1em; padding: 0px; border: 0px; vertical-align: baseline; background-color: #ffffff; clear: both; word-wrap: break-word; font-family: Arial, 'Liberation Sans', 'DejaVu Sans', sans-serif; line-height: 18px; text-align: left; ">Note: by default, git creates a "lightweight" tag (basically a reference to a specific revision). The "right" way is to use the&nbsp;<code style="margin: 0px; padding: 1px 5px; border: 0px; vertical-align: baseline; background-color: #eeeeee; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, serif; ">-a</code>&nbsp;flag. This will launch your editor asking for a tag message (identical to asking for a commit message, you can also use the&nbsp;<code style="margin: 0px; padding: 1px 5px; border: 0px; vertical-align: baseline; background-color: #eeeeee; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, serif; ">-m</code>&nbsp;flag to supply the tag message on the command line). Using an annotated tag creates an object with its own ID, date, tagger (author), and optionally a GPG signature (using the&nbsp;<code style="margin: 0px; padding: 1px 5px; border: 0px; vertical-align: baseline; background-color: #eeeeee; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, serif; ">-s</code>&nbsp;tag).&nbsp;<em style="margin: 0px; padding: 0px; border: 0px; vertical-align: baseline; background-color: transparent; ">For further information on this, see&nbsp;<a href="http://www.rockstarprogrammer.org/post/2008/oct/16/git-tag-does-wrong-thing-default/" rel="nofollow" style="margin: 0px; padding: 0px; border: 0px; vertical-align: baseline; background-color: transparent; color: #4a6b82; text-decoration: none; cursor: pointer; ">this post</a></em></p><pre style="margin-top: 0px; margin-bottom: 10px; padding: 5px; border: 0px; vertical-align: baseline; background-color: #eeeeee; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, serif; overflow: auto; width: auto; max-height: 600px; line-height: 18px; text-align: left; "><code style="margin: 0px; padding: 0px; border: 0px; vertical-align: baseline; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, serif; ">git tag mytagwithmsg -a -m 'This is a tag, with message' </code></pre><p style="margin: 0px 0px 1em; padding: 0px; border: 0px; vertical-align: baseline; background-color: #ffffff; clear: both; word-wrap: break-word; font-family: Arial, 'Liberation Sans', 'DejaVu Sans', sans-serif; line-height: 18px; text-align: left; ">And to list the tags with annotations, use the&nbsp;<code style="margin: 0px; padding: 1px 5px; border: 0px; vertical-align: baseline; background-color: #eeeeee; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, serif; ">-n1</code>&nbsp;flag to show 1 line of each tag message (<code style="margin: 0px; padding: 1px 5px; border: 0px; vertical-align: baseline; background-color: #eeeeee; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, serif; ">-n245</code>&nbsp;to show the first 245 lines of each annotation, and so on):</p><pre style="margin-top: 0px; margin-bottom: 10px; padding: 5px; border: 0px; vertical-align: baseline; background-color: #eeeeee; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, serif; overflow: auto; width: auto; max-height: 600px; line-height: 18px; text-align: left; "><code style="margin: 0px; padding: 0px; border: 0px; vertical-align: baseline; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, serif; ">$ git tag -l -n1 mytagwithmsg    This is a tag, with message </code></pre><div><code style="margin: 0px; padding: 0px; border: 0px; vertical-align: baseline; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, serif; "><br /></code></div><img src ="http://www.blogjava.net/czihong/aggbug/374054.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/czihong/" target="_blank">Chan Chen</a> 2012-04-13 11:43 <a href="http://www.blogjava.net/czihong/articles/374054.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Workflow example with GIT</title><link>http://www.blogjava.net/czihong/articles/374048.html</link><dc:creator>Chan Chen</dc:creator><author>Chan Chen</author><pubDate>Fri, 13 Apr 2012 03:23:00 GMT</pubDate><guid>http://www.blogjava.net/czihong/articles/374048.html</guid><wfw:comment>http://www.blogjava.net/czihong/comments/374048.html</wfw:comment><comments>http://www.blogjava.net/czihong/articles/374048.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/czihong/comments/commentRss/374048.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/czihong/services/trackbacks/374048.html</trackback:ping><description><![CDATA[<p style="margin: 0px 0px 1em; padding: 0px; border: 0px; vertical-align: baseline; background-color: #ffffff; clear: both; word-wrap: break-word; font-family: Arial, 'Liberation Sans', 'DejaVu Sans', sans-serif; line-height: 18px; text-align: left; ">Refter to:&nbsp;<a href="http://stackoverflow.com/questions/315911/git-for-beginners-the-definitive-practical-guide/5968622#5968622">http://stackoverflow.com/questions/315911/git-for-beginners-the-definitive-practical-guide/5968622#5968622</a><br /><br />Workflow example with GIT.</p><p style="margin: 0px 0px 1em; padding: 0px; border: 0px; vertical-align: baseline; background-color: #ffffff; clear: both; word-wrap: break-word; font-family: Arial, 'Liberation Sans', 'DejaVu Sans', sans-serif; line-height: 18px; text-align: left; ">Git is extremely flexible and adapts good to any workflow, but not enforcing a particular workflow might have the negative effect of making it hard to understand what you can do with git beyond the linear "backup" workflow, and how useful branching can be for example.</p><p style="margin: 0px 0px 1em; padding: 0px; border: 0px; vertical-align: baseline; background-color: #ffffff; clear: both; word-wrap: break-word; font-family: Arial, 'Liberation Sans', 'DejaVu Sans', sans-serif; line-height: 18px; text-align: left; ">This&nbsp;<a href="http://nvie.com/posts/a-successful-git-branching-model/" rel="nofollow" style="margin: 0px; padding: 0px; border: 0px; vertical-align: baseline; background-color: transparent; color: #4a6b82; text-decoration: none; cursor: pointer; ">blog post</a>&nbsp;explains nicely a very simple but effective workflow that is really easy to setup using git.</p><p style="margin: 0px 0px 1em; padding: 0px; border: 0px; vertical-align: baseline; background-color: #ffffff; clear: both; word-wrap: break-word; font-family: Arial, 'Liberation Sans', 'DejaVu Sans', sans-serif; line-height: 18px; text-align: left; ">quoting from the blog post: We consider origin/master to be the main branch where the source code of HEAD always reflects a production-ready state:</p><p style="margin: 0px 0px 1em; padding: 0px; border: 0px; vertical-align: baseline; background-color: #ffffff; clear: both; word-wrap: break-word; font-family: Arial, 'Liberation Sans', 'DejaVu Sans', sans-serif; line-height: 18px; text-align: left; ">The workflow has become popular enough to have made a project that implements this workflow:&nbsp;<a href="https://github.com/nvie/gitflow" rel="nofollow" style="margin: 0px; padding: 0px; border: 0px; vertical-align: baseline; background-color: transparent; color: #4a6b82; text-decoration: none; cursor: pointer; ">git-flow</a></p><p style="margin: 0px 0px 1em; padding: 0px; border: 0px; vertical-align: baseline; background-color: #ffffff; clear: both; word-wrap: break-word; font-family: Arial, 'Liberation Sans', 'DejaVu Sans', sans-serif; line-height: 18px; text-align: left; ">Nice illustration of a simple workflow, where you make all your changes in develop, and only push to master when the code is in a production state:</p><p style="margin: 0px 0px 1em; padding: 0px; border: 0px; vertical-align: baseline; background-color: #ffffff; clear: both; word-wrap: break-word; font-family: Arial, 'Liberation Sans', 'DejaVu Sans', sans-serif; line-height: 18px; text-align: left; "><img src="http://i.stack.imgur.com/NAOZI.png" alt="simple workflow" style="margin: 0px; padding: 0px; border: 0px; vertical-align: baseline; background-color: transparent; max-width: 640px; " /></p><p style="margin: 0px 0px 1em; padding: 0px; border: 0px; vertical-align: baseline; background-color: #ffffff; clear: both; word-wrap: break-word; font-family: Arial, 'Liberation Sans', 'DejaVu Sans', sans-serif; line-height: 18px; text-align: left; ">Now let's say you want to work on a new feature, or on refactoring a module. You could create a new branch, what we could call a "feature" branch, something that will take some time and might break some code. Once your feature is "stable enough" and want to move it "closer" to production, you merge your feature branch into develop. When all the bugs are sorted out after the merge and your code passes all tests rock solid, you push your changes into master.</p><p style="margin: 0px 0px 1em; padding: 0px; border: 0px; vertical-align: baseline; background-color: #ffffff; clear: both; word-wrap: break-word; font-family: Arial, 'Liberation Sans', 'DejaVu Sans', sans-serif; line-height: 18px; text-align: left; ">During all this process, you find a terrible security bug, that has to be fixed right away. You could have a branch called hotfixes, that make changes that are pushed quicker back into production than the normal "develop" branch.</p><p style="margin: 0px 0px 1em; padding: 0px; border: 0px; vertical-align: baseline; background-color: #ffffff; clear: both; word-wrap: break-word; font-family: Arial, 'Liberation Sans', 'DejaVu Sans', sans-serif; line-height: 18px; text-align: left; ">Here you have an illustration of how this feature/hotfix/develop/production workflow might look like (well explained in the blog post, and I repeat, the blog post explains the whole process in a lot more detail and a lot better than I do.</p><p style="margin: 0px 0px 1em; padding: 0px; border: 0px; vertical-align: baseline; background-color: #ffffff; clear: both; word-wrap: break-word; font-family: Arial, 'Liberation Sans', 'DejaVu Sans', sans-serif; line-height: 18px; text-align: left; "><img src="http://i.stack.imgur.com/6rDUk.png" alt="Git workflow example" style="margin: 0px; padding: 0px; border: 0px; vertical-align: baseline; background-color: transparent; max-width: 640px; " /></p><img src ="http://www.blogjava.net/czihong/aggbug/374048.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/czihong/" target="_blank">Chan Chen</a> 2012-04-13 11:23 <a href="http://www.blogjava.net/czihong/articles/374048.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Git Cheat Sheet</title><link>http://www.blogjava.net/czihong/articles/373614.html</link><dc:creator>Chan Chen</dc:creator><author>Chan Chen</author><pubDate>Mon, 09 Apr 2012 03:15:00 GMT</pubDate><guid>http://www.blogjava.net/czihong/articles/373614.html</guid><wfw:comment>http://www.blogjava.net/czihong/comments/373614.html</wfw:comment><comments>http://www.blogjava.net/czihong/articles/373614.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/czihong/comments/commentRss/373614.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/czihong/services/trackbacks/373614.html</trackback:ping><description><![CDATA[<a></a><br /><img src="http://www.blogjava.net/images/blogjava_net/czihong/git-cheat-sheet-medium.png" alt="" align="left" width="900" height="695" /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br />For more, please read:&nbsp;<a href="http://help.github.com/git-cheat-sheets/">http://help.github.com/git-cheat-sheets/</a>&nbsp;<br />&nbsp;<img src ="http://www.blogjava.net/czihong/aggbug/373614.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/czihong/" target="_blank">Chan Chen</a> 2012-04-09 11:15 <a href="http://www.blogjava.net/czihong/articles/373614.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>