Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to push a local Git repository to another computer?

Tags:

git

git-push

I have a local Git repository setup on my laptop. I would like to push it to my desktop.

How can I do that?

like image 652
nubela Avatar asked May 22 '10 12:05

nubela


People also ask

How do I move a git repository to another computer?

For your case, the best way to do it is to copy over the folder (copy, scp, cp, robocopy - whichever) to the new computer and delete the old folder.


1 Answers

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.

like image 151
VonC Avatar answered Sep 18 '22 00:09

VonC