Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is a simple way to Git Push to another machine?

Tags:

git

I thought I can do the following:

machine1 $ cd /
           mkdir try-git
           cd try-git
           git init

machine2 $ git push ssh://[email protected]//try-git master

and that's it? machine1 will have all the files then? (machine2's current directory is a git repo). But on machine2, I keep on having git-receive-pack: command not found, but both machines have the latest Git 1.7.4 installed...


update: seems like I need to add

PATH=$PATH:/usr/local/git/bin

to both machine's .bashrc

but why and won't invoking bash add more and more path to it.

like image 685
nonopolarity Avatar asked Apr 04 '11 02:04

nonopolarity


1 Answers

It looks like you might have missed out on Git's notion of remotes. The top-level git remote command helps you perform some common operations. In particular, you'll want to create a remote:

git remote add foobar username@hostname/path/to/repo.git

And now you can use that remote's name instead of the URL:

git pull foobar master
git push foobar

If you've created a repository locally, then created the authoritative "central" one (common if you're the originator of a project), you might want to give your remote the default name origin, so that it'll feel like you cloned from that canonical repository. By default, git push (with no arguments) pushes all matching branches to origin, so this can be pretty handy.

You may also want to set up tracking branches, for example:

git branch --set-upstream master origin/master

That will tell Git that, when you have your master branch checked out and you run git pull (with no arguments), it should fetch and merge with origin's master branch.

like image 115
Cascabel Avatar answered Nov 08 '22 10:11

Cascabel