Skip to content

Commit

Permalink
Added fast-import tip.
Browse files Browse the repository at this point in the history
  • Loading branch information
blynn committed May 20, 2008
1 parent c1bc4b7 commit 1b019aa
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 1 deletion.
4 changes: 4 additions & 0 deletions book.css
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ tt, code, pre, .type {
font-size: 90%;
}

pre {
color: #0000aa;
}

ul li p {
margin-bottom:0;
}
Expand Down
2 changes: 1 addition & 1 deletion branch.txt
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ and again, the second part is ready to be reviewed.

It's easy to extend this trick for any number of parts.

=== Reorganizing a Medley Branch ===
=== Reorganizing a Medley ===

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:

Expand Down
52 changes: 52 additions & 0 deletions grandmaster.txt
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,58 @@ Git records every hash of a commit it computes in `.git/logs`. The subdirectory

Eventually, you may want to run *git gc \--prune* to recover space. Be aware that doing so prevents you from recovering lost HEADs.

=== Making History ===

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.

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.

As an example, paste the following listing into temporary file, such as `/tmp/history`:
----------------------------------
commit refs/heads/master
committer "Alice" <[email protected]> Thu, 01 Jan 1970 00:00:00 +0000
data <<EOT
Initial commit.
EOT

M 100644 inline hello.c
data <<EOT
#include <stdio.h>

int main() {
printf("Hello, world!\n");
return 0;
}
EOT


commit refs/heads/master
committer "Bob" <[email protected]> Tue, 14 Mar 2000 01:59:26 -0800
data <<EOT
Replace printf() with write().
EOT

M 100644 inline hello.c
data <<EOT
#include <unistd.h>

int main() {
write(1, "Hello, world!\n", 14);
return 0;
}
EOT

----------------------------------

Then create a Git repository from this temporary file by typing:

$ mkdir project; cd project; git init
$ git fast-import < /tmp/history

You can checkout the latest version of the project with:

$ git checkout master .

=== Building On Git ===

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.
Expand Down

0 comments on commit 1b019aa

Please sign in to comment.