What is an easy way to git push another machine?

I thought I could do the following:

machine1 $ cd / mkdir try-git cd try-git git init machine2 $ git push ssh:// loginname@192.168.1.123 //try-git master 

and what is it? will machine1 have all the files then? ( machine2 current directory is git repo). But on machine2 I continue to have git-receive-pack: command not found , but both machines have the latest version of git 1.7.4 ...


update: it looks like I need to add

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

for both .bashrc machines

but why and will not cause bash to add more and more paths to it.

+4
source share
3 answers

Are you trying to push the whole repo to another machine? The easiest way is to make a "git clone" from the destination computer to the source computer.

+2
source

If the remote system does not have Git in the default PATH system (which is probably different from the PATH in your login shell), you should tell it where to find git -receive-pack.

You mentioned the path /usr/local/git/bin/git-receive-pack , so try this:

 git push --receive-pack=/usr/local/git/bin/git-receive-pack ssh:// user@machine1 :/try-git master 

The path specified in --receive-pack= is the path to git -receive-pack on the remote system.

You can save the git -receive-pack path as part of "remote" to save text input if you plan to access this repository many times:

 git remote add machine1 ssh:// user@machine1 :/try-git git config remote.machine1.receivepack /usr/local/git/bin/git-receive-pack git config remote.machine1.uploadpack /usr/local/git/bin/git-upload-pack 

Use it as follows:

 git push machine1 master 

The remote.<remote-name>.uploadpack configuration configuration eliminates the need for the --upload-pack= option for git fetch (and git pull ) in the same way as remote.<remote-name>.receivepack eliminates the need to specify --receive-pack= using git push .


In your specific scenario, you click on a non-bare repository. You also probably clicked on the branch that was checked (pushing master on machine2 on master on machine1). Modern versions of Git will give you an error when trying to do this. You can override this warning by setting specific configuration variables, but this is usually not the best way to work.

+7
source

It looks like you might have missed the idea of ​​Git remotes. The top-level git remote command helps you perform some common operations. In particular, you will want to create a remote control:

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

And now you can use this remote name instead of the URL:

 git pull foobar master git push foobar 

If you created a local local repository, then created an authoritative "central" (common if you are the initiator of the project), you can tell your remote name the default origin so that it "I feel like you are cloned from this canonical repository. By default, git push (without arguments) pushes all the corresponding branches to the beginning, so this can be very convenient.

You can also set up tracking branches, for example:

 git branch --set-upstream master origin/master 

This tells Git that when you check your main branch and you run git pull (with no arguments), it should extract and merge with the source source branch.

+3
source

Source: https://habr.com/ru/post/1346488/


All Articles