I’ve been using git for a bit now since Rick switched Mephisto to git, but I’ve only been using an existing repository, and not using the full thing just yet.
So as I’m starting a new project, I have been taking a few notes to get started with a new project (I’m also testing gitorious.org in the process, a free git repository provided by Johan Sørensen)
First, I created a .gitignore file to filter out anything unwanted. On a Mac, for example, it is alway a good idea to add:
.DS_Store
Then to create the initial repository and commit locally
$ cd vendor/plugin/rur $ git init Initialized empty Git repository in .git/ $ git add . $ git commit
Now the big push:
$ git push git@gitorious.org:rur/mainline.git The authenticity of host 'gitorious.org (67.207.146.32)' can't be established. RSA key fingerprint is 1d:0f:80:3b:95:c5:a8:08:85:f6:fc:0a:b2:54:52:bb. Are you sure you want to continue connecting (yes/no)? yes Warning: Permanently added 'gitorious.org,67.207.146.32' (RSA) to the list of known hosts. No refs in common and none specified; doing nothing. fatal: The remote end hung up unexpectedly
Whoops! Not quite what I expected. Let’s try to pull first then?
$ git clone git@gitorious.org:rur/mainline.git Initialized empty Git repository in /Users/psq/tmp/mainline/.git/ fatal: no matching remote head fetch-pack from 'git@gitorious.org:rur/mainline.git' failed.
Hmm, not quite either.
Looking at the gitorious “faq”http://gitorious.org/about/faq provides the answer :) Add the remote and master definitions to .git/config:
[core] repositoryformatversion = 0 filemode = true bare = false logallrefupdates = true [remote "origin"] url = git@gitorious.org:rur/mainline.git fetch = +refs/heads/*:refs/remotes/origin/* [branch "master"] remote = origin merge = refs/heads/master
(Change to match your project).
Then, try to push again:
$ git push origin master updating 'refs/heads/master' from 0000000000000000000000000000000000000000 to 74bbfc838d4984ee81d5560daee3511fe044d36e Generating pack... Done counting 22 objects. Deltifying 22 objects... 100% (22/22) done Writing 22 objects... 100% (22/22) done Total 22 (delta 0), reused 0 (delta 0) refs/heads/master: 0000000000000000000000000000000000000000 -> 74bbfc838d4984ee81d5560daee3511fe044d36e
Finally! And checking the gitorious site, the code has been pushed!
(You can get your push and pull urls from the mainline page.
To get started locally with an existing project, just use the pull url
git clone git://gitorious.org/rur/mainline.git
Now, if I can figure out the best way to get an svn mirror from gitorious, I’ll be in business!
Source (and a good tutorial): A tutorial introduction to git (for version 1.5.1 or newer)
A final note: the project referenced here is not quite fully baked, so use at your own risk…
there is a follow up for git svn mirror