Take the 2008 Git User's Survey and help out! [ hide ]

public
Description: A guide to using Git
Homepage: http://cs.stanford.edu/~blynn/gitmagic/
Clone URL: git://github.com/blynn/gitmagic.git
Search Repo:
Added fast-import tip.
blynn (author)
Tue May 20 07:55:06 -0700 2008
commit  1b019aa7cb4f878b01d1e6f9c99d9263e5def0a2
tree    126dc7c620f59a11d007c1e032017bb73d7bca22
parent  c1bc4b763a4469a7345ff339cfb0dc95e6cbe2b3
...
8
9
10
 
 
 
 
11
12
13
...
8
9
10
11
12
13
14
15
16
17
0
@@ -8,6 +8,10 @@ tt, code, pre, .type {
0
     font-size: 90%;
0
 }
0
 
0
+pre {
0
+ color: #0000aa;
0
+}
0
+
0
 ul li p {
0
     margin-bottom:0;
0
 }
...
117
118
119
120
 
121
122
123
...
117
118
119
 
120
121
122
123
0
@@ -117,7 +117,7 @@ and again, the second part is ready to be reviewed.
0
 
0
 It's easy to extend this trick for any number of parts.
0
 
0
-=== Reorganizing a Medley Branch ===
0
+=== Reorganizing a Medley ===
0
 
0
 Perhaps you like to work on all aspects of a project in the same branch, but want others to avoid seeing works-in-progress, and want your commits neatly organized. Then after cloning:
0
 
...
139
140
141
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
142
143
144
...
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
0
@@ -139,6 +139,58 @@ Git records every hash of a commit it computes in `.git/logs`. The subdirectory
0
 
0
 Eventually, you may want to run *git gc \--prune* to recover space. Be aware that doing so prevents you from recovering lost HEADs.
0
 
0
+=== Making History ===
0
+
0
+Want to migrate a project to Git? If it's managed with one of the more well-known systems, then chances are someone has already written a script to export the whole history to Git.
0
+
0
+Otherwise, take a look at *git fast-import*. This command takes text input in a specific format and creates Git history from scratch. Typically a script is cobbled together and run once to feed this command, migrating the project in a single shot.
0
+
0
+As an example, paste the following listing into temporary file, such as `/tmp/history`:
0
+----------------------------------
0
+commit refs/heads/master
0
+committer "Alice" <alice@example.com> Thu, 01 Jan 1970 00:00:00 +0000
0
+data <<EOT
0
+Initial commit.
0
+EOT
0
+
0
+M 100644 inline hello.c
0
+data <<EOT
0
+#include <stdio.h>
0
+
0
+int main() {
0
+ printf("Hello, world!\n");
0
+ return 0;
0
+}
0
+EOT
0
+
0
+
0
+commit refs/heads/master
0
+committer "Bob" <bob@example.com> Tue, 14 Mar 2000 01:59:26 -0800
0
+data <<EOT
0
+Replace printf() with write().
0
+EOT
0
+
0
+M 100644 inline hello.c
0
+data <<EOT
0
+#include <unistd.h>
0
+
0
+int main() {
0
+ write(1, "Hello, world!\n", 14);
0
+ return 0;
0
+}
0
+EOT
0
+
0
+----------------------------------
0
+
0
+Then create a Git repository from this temporary file by typing:
0
+
0
+ $ mkdir project; cd project; git init
0
+ $ git fast-import < /tmp/history
0
+
0
+You can checkout the latest version of the project with:
0
+
0
+ $ git checkout master .
0
+
0
 === Building On Git ===
0
 
0
 In true UNIX fashion, Git's design allows it to be easily used as a low-level component of other programs. There are GUI interfaces, web interfaces, alternative command-line interfaces, and perhaps soon you will have a script or two of your own that calls Git.

Comments

    No one has commented yet.