Skip to content

Commit e73e349

Browse files
committed
Update documentation
1 parent 37e6d24 commit e73e349

10 files changed

+322
-3
lines changed

archives.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626
<h1>Archives for Generic Surname</h1>
2727

2828
<dl>
29+
<dt>Sun 12 October 2014</dt>
30+
<dd><a href="http://jrsmith3.github.io/merging-a-subdirectory-from-another-repo-via-git-subtree.html">Merging a subdirectory from another repo via git-subtree</a></dd>
2931
<dt>Thu 26 June 2014</dt>
3032
<dd><a href="http://jrsmith3.github.io/scratchwork-branches.html">Scratchwork branches</a></dd>
3133
<dt>Sun 22 June 2014</dt>

author/joshua-ryan-smith.html

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,20 @@
4848
</footer></header>
4949
<div id="post-container">
5050
<ol id="post-list">
51+
<li>
52+
<article class="post-entry">
53+
<header class="entry-header">
54+
<time class="post-time" datetime="2014-10-12T00:00:00" pubdate>
55+
Sun 12 October 2014
56+
</time>
57+
<a href="http://jrsmith3.github.io/merging-a-subdirectory-from-another-repo-via-git-subtree.html" rel="bookmark"><h1>Merging a subdirectory from another repo via git-subtree</h1></a>
58+
</header>
59+
<section class="post-content">
60+
<p>Merging a directory from a source repo into a directory in a target repo without losing commit history using <code>git-subtree</code>.</p>
61+
</section>
62+
</article>
63+
</li>
64+
<hr/>
5165
<li>
5266
<article class="post-entry">
5367
<header class="entry-header">

authors.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
<![endif]-->
2424

2525
<div id="wrapper">
26-
<h1>Authors on Generic Surname</h1> <li><a href="http://jrsmith3.github.io/author/joshua-ryan-smith.html">Joshua Ryan Smith</a> (9)</li>
26+
<h1>Authors on Generic Surname</h1> <li><a href="http://jrsmith3.github.io/author/joshua-ryan-smith.html">Joshua Ryan Smith</a> (10)</li>
2727
</div>
2828

2929
<script>

categories.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
<div id="wrapper">
2626
<ul>
2727
<li><a href="http://jrsmith3.github.io/category/blog.html">Blog</a></li>
28+
<li><a href="http://jrsmith3.github.io/category/git-git-subtree.html">git, git-subtree</a></li>
2829
</ul>
2930
</div>
3031

category/git-git-subtree.html

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
<!DOCTYPE html>
2+
<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
3+
<!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8"> <![endif]-->
4+
<!--[if IE 8]> <html class="no-js lt-ie9"> <![endif]-->
5+
<!--[if gt IE 8]><!--> <html class="no-js"> <!--<![endif]-->
6+
<head>
7+
<meta charset="utf-8">
8+
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
9+
<title>Generic Surname - git, git-subtree</title>
10+
<meta name="description" content="">
11+
<meta name="viewport" content="width=device-width">
12+
<link rel="stylesheet" href="http://jrsmith3.github.io/theme/css/normalize.css">
13+
<link href='//fonts.googleapis.com/css?family=Lato' rel='stylesheet' type='text/css'>
14+
<link href='//fonts.googleapis.com/css?family=Oswald' rel='stylesheet' type='text/css'>
15+
<link rel="stylesheet" href="http://jrsmith3.github.io/theme/css/font-awesome.min.css">
16+
<link rel="stylesheet" href="http://jrsmith3.github.io/theme/css/main.css">
17+
18+
<link rel="stylesheet" href="http://jrsmith3.github.io/theme/css/blog.css">
19+
<link rel="stylesheet" href="http://jrsmith3.github.io/theme/css/github.css">
20+
<link href="http://jrsmith3.github.io/feeds/all.atom.xml" type="application/atom+xml" rel="alternate" title="Generic Surname Atom Feed" />
21+
<script src="http://jrsmith3.github.io/theme/js/vendor/modernizr-2.6.2.min.js"></script>
22+
</head>
23+
<body>
24+
<!--[if lt IE 7]>
25+
<p class="chromeframe">You are using an <strong>outdated</strong> browser. Please <a href="http://browsehappy.com/">upgrade your browser</a> or <a href="http://www.google.com/chromeframe/?redirect=true">activate Google Chrome Frame</a> to improve your experience.</p>
26+
<![endif]-->
27+
28+
<div id="wrapper">
29+
<header id="sidebar" class="side-shadow">
30+
<hgroup id="site-header">
31+
<a id="site-title" href="http://jrsmith3.github.io"><h1><i class="icon-coffee"></i> Generic Surname</h1></a>
32+
<p id="site-desc"></p>
33+
</hgroup>
34+
<nav>
35+
<ul id="nav-links">
36+
<li><a href="http://jrsmith3.github.io/pages/about.html">About</a></li>
37+
<li><a href="http://jrsmith3.github.io/pages/contact.html">Contact</a></li>
38+
<li><a href="http://jrsmith3.github.io/pages/curriculum-vitae.html">Curriculum Vitae</a></li>
39+
</ul>
40+
</nav>
41+
<footer id="site-info">
42+
<p>
43+
Proudly powered by <a href="http://getpelican.com/" target="pelican">Pelican</a> and <a href="http://python.org/" target="python">Python</a>. Theme by <a href="https://github.com/hdra/pelican-cait" target="github">hndr</a>.
44+
</p>
45+
<p>
46+
Textures by <a href="http://subtlepatterns.com/" target="subtlepatterns">Subtle Pattern</a>. Font Awesome by <a href="http://fortawesome.github.io/Font-Awesome/" target="github">Dave Grandy</a>.
47+
</p>
48+
</footer></header>
49+
<div id="post-container">
50+
<ol id="post-list">
51+
<li>
52+
<article class="post-entry">
53+
<header class="entry-header">
54+
<time class="post-time" datetime="2014-10-12T00:00:00" pubdate>
55+
Sun 12 October 2014
56+
</time>
57+
<a href="http://jrsmith3.github.io/merging-a-subdirectory-from-another-repo-via-git-subtree.html" rel="bookmark"><h1>Merging a subdirectory from another repo via git-subtree</h1></a>
58+
</header>
59+
<section class="post-content">
60+
<p>Merging a directory from a source repo into a directory in a target repo without losing commit history using <code>git-subtree</code>.</p>
61+
</section>
62+
</article>
63+
</li>
64+
<hr/>
65+
</ol>
66+
67+
</div>
68+
</div>
69+
70+
<script>
71+
var _gaq=[['_setAccount','UA-1567200-4'],['_trackPageview']];
72+
(function(d,t){var g=d.createElement(t),s=d.getElementsByTagName(t)[0];
73+
g.src=('https:'==location.protocol?'//ssl':'//www')+'.google-analytics.com/ga.js';
74+
s.parentNode.insertBefore(g,s)}(document,'script'));
75+
</script>
76+
<script src="http://jrsmith3.github.io/theme/js/main.js"></script>
77+
</body>
78+
</html>

feeds/all-en.atom.xml

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,33 @@
11
<?xml version="1.0" encoding="utf-8"?>
2-
<feed xmlns="http://www.w3.org/2005/Atom"><title>Generic Surname</title><link href="http://jrsmith3.github.io/" rel="alternate"></link><link href="http://jrsmith3.github.io/feeds/all-en.atom.xml" rel="self"></link><id>http://jrsmith3.github.io/</id><updated>2014-06-26T00:00:00-04:00</updated><entry><title>Scratchwork branches</title><link href="http://jrsmith3.github.io/scratchwork-branches.html" rel="alternate"></link><updated>2014-06-26T00:00:00-04:00</updated><author><name>Joshua Ryan Smith</name></author><id>tag:jrsmith3.github.io,2014-06-26:scratchwork-branches.html</id><summary type="html">&lt;p&gt;I have a question that I'd like to pose to more advanced software developers if any are out there.&lt;/p&gt;
2+
<feed xmlns="http://www.w3.org/2005/Atom"><title>Generic Surname</title><link href="http://jrsmith3.github.io/" rel="alternate"></link><link href="http://jrsmith3.github.io/feeds/all-en.atom.xml" rel="self"></link><id>http://jrsmith3.github.io/</id><updated>2014-10-12T00:00:00-04:00</updated><entry><title>Merging a subdirectory from another repo via git-subtree</title><link href="http://jrsmith3.github.io/merging-a-subdirectory-from-another-repo-via-git-subtree.html" rel="alternate"></link><updated>2014-10-12T00:00:00-04:00</updated><author><name>Joshua Ryan Smith</name></author><id>tag:jrsmith3.github.io,2014-10-12:merging-a-subdirectory-from-another-repo-via-git-subtree.html</id><summary type="html">&lt;p&gt;Greg Wilson &lt;a href="https://twitter.com/jiffyclub/status/519920529038262272"&gt;wanted to know&lt;/a&gt; how to move a directory from one git repo to another while preserving history. Ash Wilson posted a &lt;a href="https://gist.github.com/smashwilson/015e6a3abfbf7af73d31"&gt;gist&lt;/a&gt; demonstrating a merge and delete strategy. A similar result can be achieved using &lt;code&gt;git-subtree&lt;/code&gt;. The advantage of the &lt;code&gt;git-subtree&lt;/code&gt; approach is that &lt;code&gt;git-subtree&lt;/code&gt; creates a new branch containing only the commits pertaining to files located in a specified subdirectory. Like Ash's approach, &lt;code&gt;git-subtree&lt;/code&gt; will result in the final state of the target repo is such that changes to the target repo won't get pushed back upstream to the source.&lt;/p&gt;
3+
&lt;p&gt;If you want to carry &lt;em&gt;all&lt;/em&gt; of the commit history from another repo into the target repo, Ash's approach is probably the way to go. If you want only the commits pertaining to files within a subdirectory of the source repo, &lt;code&gt;git-subtree&lt;/code&gt; is the way to go.&lt;/p&gt;
4+
&lt;p&gt;The workflow with &lt;code&gt;git-subtree&lt;/code&gt; is pretty simple: you specify a subdirectory in a source repo which you want to break out, then you merge those commits into a subdirectory in a target repo.&lt;/p&gt;
5+
&lt;p&gt;I am modifying my example slightly from Ash's because it looks like the &lt;code&gt;/openstack-swift/&lt;/code&gt; directory has been removed from jclouds/jclouds-labs-openstack as of 2014-10-12. I will use &lt;code&gt;openstack-glance&lt;/code&gt; instead. Thus, we're moving the &lt;code&gt;/openstack-glance/&lt;/code&gt; directory from jclouds/jclouds-labs-openstack to &lt;code&gt;/apis/openstack-glance/&lt;/code&gt; in jclouds/jclouds. The two approaches begin in the same way.&lt;/p&gt;
6+
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="cp"&gt;# Clone the target repo&lt;/span&gt;
7+
&lt;span class="n"&gt;git&lt;/span&gt; &lt;span class="n"&gt;clone&lt;/span&gt; &lt;span class="n"&gt;git&lt;/span&gt;&lt;span class="err"&gt;@&lt;/span&gt;&lt;span class="n"&gt;github&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;com&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;&lt;span class="n"&gt;jclouds&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;jclouds&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;git&lt;/span&gt;
8+
&lt;span class="n"&gt;cd&lt;/span&gt; &lt;span class="n"&gt;jclouds&lt;/span&gt;
9+
10+
&lt;span class="cp"&gt;# Add the source repository as a remote, and perform the initial fetch.&lt;/span&gt;
11+
&lt;span class="n"&gt;git&lt;/span&gt; &lt;span class="n"&gt;remote&lt;/span&gt; &lt;span class="n"&gt;add&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;f&lt;/span&gt; &lt;span class="n"&gt;sourcerepo&lt;/span&gt; &lt;span class="n"&gt;git&lt;/span&gt;&lt;span class="err"&gt;@&lt;/span&gt;&lt;span class="n"&gt;github&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;com&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;&lt;span class="n"&gt;jclouds&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;jclouds&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;labs&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;openstack&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;git&lt;/span&gt;
12+
13+
&lt;span class="cp"&gt;# Create a branch based on the source repositories&amp;#39; branch that contains the state you want to copy.&lt;/span&gt;
14+
&lt;span class="n"&gt;git&lt;/span&gt; &lt;span class="n"&gt;checkout&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;b&lt;/span&gt; &lt;span class="n"&gt;staging&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;branch&lt;/span&gt; &lt;span class="n"&gt;sourcerepo&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;master&lt;/span&gt;
15+
16+
&lt;span class="cp"&gt;# Here&amp;#39;s where the two approaches diverge.&lt;/span&gt;
17+
&lt;span class="cp"&gt;# Create a synthetic branch using the commits in `/openstack-glance/` from `sourcerepo`&lt;/span&gt;
18+
&lt;span class="n"&gt;git&lt;/span&gt; &lt;span class="n"&gt;subtree&lt;/span&gt; &lt;span class="n"&gt;split&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;P&lt;/span&gt; &lt;span class="n"&gt;openstack&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;glance&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;b&lt;/span&gt; &lt;span class="n"&gt;openstack&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;glance&lt;/span&gt;
19+
20+
&lt;span class="cp"&gt;# Checkout `master` and add the new `openstack-glance` branch into `/apis/openstack-glance/`. At this point, the desired result will have been achieved.&lt;/span&gt;
21+
&lt;span class="n"&gt;git&lt;/span&gt; &lt;span class="n"&gt;checkout&lt;/span&gt; &lt;span class="n"&gt;master&lt;/span&gt;
22+
&lt;span class="n"&gt;git&lt;/span&gt; &lt;span class="n"&gt;subtree&lt;/span&gt; &lt;span class="n"&gt;add&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;P&lt;/span&gt; &lt;span class="n"&gt;apis&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;openstack&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;glance&lt;/span&gt; &lt;span class="n"&gt;openstack&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;glance&lt;/span&gt;
23+
24+
&lt;span class="cp"&gt;# Clean up by removing the commits from the `openstack-glance` branch and the `sourcerepo` remote.&lt;/span&gt;
25+
&lt;span class="n"&gt;git&lt;/span&gt; &lt;span class="n"&gt;branch&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;D&lt;/span&gt; &lt;span class="n"&gt;openstack&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;glance&lt;/span&gt; &lt;span class="n"&gt;staging&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;branch&lt;/span&gt;
26+
&lt;span class="n"&gt;git&lt;/span&gt; &lt;span class="n"&gt;remote&lt;/span&gt; &lt;span class="n"&gt;rm&lt;/span&gt; &lt;span class="n"&gt;sourcerepo&lt;/span&gt;
27+
&lt;/pre&gt;&lt;/div&gt;
28+
29+
30+
&lt;p&gt;And that's it. No additional (potentially superfluous) commits were brought into the &lt;code&gt;jclouds&lt;/code&gt; repo from the &lt;code&gt;jclouds-labs-openstack&lt;/code&gt; repo.&lt;/p&gt;</summary></entry><entry><title>Scratchwork branches</title><link href="http://jrsmith3.github.io/scratchwork-branches.html" rel="alternate"></link><updated>2014-06-26T00:00:00-04:00</updated><author><name>Joshua Ryan Smith</name></author><id>tag:jrsmith3.github.io,2014-06-26:scratchwork-branches.html</id><summary type="html">&lt;p&gt;I have a question that I'd like to pose to more advanced software developers if any are out there.&lt;/p&gt;
331
&lt;p&gt;Yesterday I wrote some code and tests to implement some medium-complex functionality (branch &lt;code&gt;surf_enh&lt;/code&gt; in the picture). The result was ok, but I ended up with a situation where I had painted myself into a corner. So today I started over pretty much from scratch; I reverted back to the point in the repo where I had started yesterday, and applied the lessons I had learned (branch &lt;code&gt;slab&lt;/code&gt;) while avoiding the cul-de-sac I ended up in yesterday. A lot of the code in &lt;code&gt;slab&lt;/code&gt; is copied from &lt;code&gt;surf_enh&lt;/code&gt; with some minor modifications.&lt;/p&gt;
432
&lt;p&gt;&lt;img alt="Two days' work." src="images/two_days.png" /&gt;&lt;/p&gt;
533
&lt;p&gt;My question is: what do I do with branch &lt;code&gt;surf_enh&lt;/code&gt;? I'm thinking about this branch in terms of an early draft of a manuscript; some days you write copy with the understanding that you will pretty much completely rewrite it from scratch on a subsequent revision. When I write manuscripts or papers, I like to keep earlier revisions for posterity. Similarly, I would like to keep the commits and commit messages in &lt;code&gt;surf_enh&lt;/code&gt;. However, it seems like keeping a whole named branch in the repo would be crufty.&lt;/p&gt;

0 commit comments

Comments
 (0)