<?xml version="1.0" encoding="UTF-8" standalone="yes"?><oembed><version><![CDATA[1.0]]></version><provider_name><![CDATA[Software is Crap]]></provider_name><provider_url><![CDATA[https://davmac.wordpress.com]]></provider_url><author_name><![CDATA[davmac]]></author_name><author_url><![CDATA[https://davmac.wordpress.com/author/davmac/]]></author_url><title><![CDATA[Understanding Git in 5&nbsp;minutes]]></title><type><![CDATA[link]]></type><html><![CDATA[<p>Git it seems is known for being confusing and difficult to learn. If you are transitioning from a &#8220;traditional&#8221; versioning system such as CVS or Subversion, here are the things you need to know:</p>
<ul>
<li>A &#8220;working copy&#8221; in <em>Subversion</em> is a copy of the various files in a subversion repository, together with metadata linking it back to the repository. When using Git, your working copy (sometimes referred to as &#8220;working directory&#8221;, apparently, in Git parlance) is actually hosted inside a local copy (<em>clone</em>) of the remote repository. To create this clone you use the &#8220;git clone&#8221; command. So, generally, you would <strong>use</strong> <strong>&#8220;git clone&#8221; where you would have used &#8220;svn checkout&#8221;.</strong></li>
<li>A repository has a collection of branches, some of which may be <em>remote-tracking </em>branches (exact copies of the upstream repository), and the rest of which are local branches (which generally have an associated upstream and remote-tracking branch).</li>
<li>In Git you make changes by committing them to the local branch. You can later <em>push</em> these commits upstream, which (if successful) also updates the associated remote tracking branch in your repository.</li>
<li>But actually, commit is a two-stage operation in Git. First you <em>stage</em> the files you want to commit (&#8220;git add&#8221; command), then you perform the commit (&#8220;git commit&#8221;).</li>
<li>You can <em>fetch</em> any new changes from the remote repository into a remote tracking branch, and you can <em>merge</em> these changes into your local branch; You can combine both operations by doing a <em>pull</em> (&#8220;git pull&#8221;), which is the normal way of doing it<em>.</em></li>
<li>A Git &#8220;checkout&#8221; is to replace your working copy with a copy of a branch. <strong>So you switch branches use the &#8220;git checkout&#8221; command</strong>. You cannot (or at least don&#8217;t normally) checkout remote tracking branches directly; you instead checkout the associated local branch.</li>
<li>So actually a Git repository contains these different things:
<ul>
<li>A collection of branches, both local and remote-tracking;</li>
<li>A working copy</li>
<li>A &#8220;stash&#8221; (of changes to be committed)</li>
<li>Some configuration</li>
<li>(a few other things not mentioned here).</li>
</ul>
</li>
<li>Except for the working copy itself, everything in a Git repository is stored in the &#8220;.git&#8221; directory within your working copy.</li>
<li>A &#8220;bare&#8221; Git repository doesn&#8217;t have a working copy (or stash). The data that would normally be inside &#8220;.git&#8221; is instead contained directly inside the repository root folder. A repository hosted on a server is often a &#8220;bare&#8221; repository; when you clone it, your clone will not be bare, so that you can perform checkouts / make commits etc.</li>
<li>Because you make commits to a local branch, a commit operation does not contact the origin server. This means that commits may occur in the origin repository simultaneously. A merge will be needed before the local branch commits can be pushed to the remote repository.</li>
<li>Git versions represent a snapshot of the repository state. They are identified by an SHA-1 checksum (of both file contents and some metadata, including version creation date and author). A Git version has a preceding version, and may have multiple preceding versions if it is the result of a merge.</li>
<li>To avoid complicating the commit history, you can <em>rebase</em> commits made to your local branch, which means that the changes they make are re-applied after the changes from remote commits. This re-writes the history of your commits, effectively making it appear that your commits were performed after the remote changes, instead of interleaved with them. (You can&#8217;t rebase commits after you have pushed them).</li>
</ul>
]]></html></oembed>