<?xml version="1.0" encoding="UTF-8"?>
<wiki>
  <body>&lt;h1&gt;Initialize a new repository&lt;/h1&gt;
&lt;p&gt;If you are using Github.com then this is the means of initializing a new remote repository. The repository is called &amp;#8220;project1&amp;#8221; in this example.&lt;/p&gt;
&lt;pre&gt;
mkdir project1
cd project1
git init
touch README
git add README
git commit -m &quot;Initialize&quot;
git remote add origin git@github.com:andrewgilmartin/project1.git 
&lt;/pre&gt;
&lt;h1&gt;Cloning an existing remote repository&lt;/h1&gt;
&lt;p&gt;Create a copy of the existing remote repository for local use.&lt;/p&gt;
&lt;pre&gt;
git clone git@github.com:andrewgilmartin/project1.git
cd project1
&lt;/pre&gt;
&lt;h1&gt;Branching&lt;/h1&gt;
&lt;p&gt;Local work should be done on a branch. (Git branches are cheap.) Branch the master (or other major) line of development for the project&lt;/p&gt;
&lt;pre&gt;
git checkout master
git branch b1
git checkout b1
...
git add ...
git commit -m &quot;...&quot;
git push origin b1
&lt;/pre&gt;
&lt;p&gt;Delete the branch when you are done. Delete the remote and then the tracking branch:&lt;/p&gt;
&lt;pre&gt;
git push origin :b1
git branch -D b1
&lt;/pre&gt;
&lt;p&gt;Be &lt;span class=&quot;caps&quot;&gt;VERY&lt;/span&gt; careful about using the colon! You can easily delete any line of development this way &amp;#8212; even master.&lt;/p&gt;
&lt;h1&gt;Normal use&lt;/h1&gt;
&lt;p&gt;Work on branch b1:&lt;/p&gt;
&lt;pre&gt;
git checkout b1
...
git add ...
git commit -m &quot;...&quot;
&lt;/pre&gt;
&lt;p&gt;Rinse and repeat. Push your changes to the remote repository to save the intermediate changes:&lt;/p&gt;
&lt;pre&gt;
git push origin b1
&lt;/pre&gt;
&lt;p&gt;By not working on master you can make this kind of intermediate backup. It also allows you to share your project&amp;#8217;s work with others.&lt;/p&gt;
&lt;h1&gt;Merging a branch&lt;/h1&gt;
&lt;p&gt;Merge branch b1&amp;#8217;s changes into master:&lt;/p&gt;
&lt;pre&gt;
git checkout master
git merge b1
git push origin master
&lt;/pre&gt;
&lt;h1&gt;Fetching and merging remote repository updates&lt;/h1&gt;
&lt;pre&gt;
git checkout master
git pull origin master
&lt;/pre&gt;
&lt;p&gt;If you don&amp;#8217;t checkout the master then the pull will be into the existing branch. Remember that pull is the same as (I think)&lt;/p&gt;
&lt;pre&gt;
git fetch origin -v master
git merge master
&lt;/pre&gt;
&lt;p&gt;Since this affects the current working directory make sure you have committed your branch changes first.&lt;/p&gt;
&lt;p&gt;&lt;span class=&quot;caps&quot;&gt;END&lt;/span&gt;&lt;/p&gt;</body>
  <created-at type="datetime">2010-02-10T00:52:56-08:00</created-at>
  <id type="integer">105355</id>
  <permalink>git-notes</permalink>
  <repository-id type="integer">99163</repository-id>
  <title>Git notes</title>
  <updated-at type="datetime">2009-01-05T07:07:59-08:00</updated-at>
  <user-id type="integer">19509</user-id>
</wiki>
