tags:

views:

81

answers:

3

Hi, I have a local git repository setup on my laptop. I would like to push it to my desktop, how can I do that?

Thanks.

+2  A: 

If you have access to a shared directory, you can (see git clone and git remote):

git clone --bare /path/to/your/laptop/repo /shared/path/to/desktop/repo.git
git remote add desktop  /shared/path/to/desktop/repo.git

That will create a bare repo, referenced in your local repo as "desktop".
Since it is bare, you can push to it (as well as pull from it if needed)

git push desktop

As the ProGit book mentions, git does support the file protocol:

The most basic is the Local protocol, in which the remote repository is in another directory on disk.
This is often used if everyone on your team has access to a shared filesystem such as an NFS mount, or in the less likely case that everyone logs in to the same computer.

VonC
+2  A: 

Here's a script that I wrote to do just this thing. The script handles all my usual initialization of new git repos

  1. creates .gitignore file
  2. initializes .git
  3. creates the bare git repo on the server
  4. sets up the local git repo to push to that remote repo

http://gist.github.com/410050

You'll definitely have to modify it to suit whatever setup you've got, especially if you're dealing with Windows laptop/desktop.

kubi
I would recommend copying your script in full in your answer (since it is not too big). Once Stack Overflow release the next cc-wiki dump (http://blog.stackoverflow.com/2009/06/stack-overflow-creative-commons-data-dump/), you are sure this script will *always* be available. Otherwise, +1
VonC
A: 

The easiest (not the best) way is to share the repository directory via LAN, and use git's file:// protocol (see man git).

For me, the best way is to use gitolite (see gitolite docs for detailed instructions).

takeshin