简体   繁体   中英

Git how to access repository Windows local machine?

I installed Git for Windows in order to clone and pull a project hosted on a remote Linux server. In my repository (D:/repositories/my-project) I launch the following commands

git clone server@192.168.56.101:/var/www/web/my-project/.git

git pull origin master

So far so good. I pull the project files whenever modifications are applied on the server. But now I'd like to pull or push from the remote server to my local repository. I tried many things but I can't figure out how to access the repository located on my local machine. Things like:

git pull duddy@my-pc:/d/repositories/my-project/.git master

just doesn't work, Git says:

ssh: Could not resolve hostname my-pc: Name or service not known fatal: Could not read from remote repository.

Can someone helps me ?

First things first, I would recommend you try simply running git pull .

If this doesn't work, try running git remote -v and check to make sure that the URL for your server is listed as an origin (server@192.168.56.101:/var/www/web/my-project/.git).

Your issue is that you are inputting the URL for your local repository in your attempt to git pull .

I suggest reading the git-pull documentation to learn more about how pull works.

Basically, you need to have some service at your workstation which serves the requests. There are following options (I did not try most of them myself, just making it up from what I know):

  1. use the windows file access. This is the easiest to setup at the windows workstation - just share the repository folder. The Linux side should somehow be able to mount windows shares (like described, for example, here: https://wiki.ubuntu.com/MountWindowsSharesPermanently ). If you manage to mount your \\\\my-pc\\repo to some /mount/my-pc-repo , then you can access it as file:///mount/my-pc-repo .

  2. run git daemon at windows. Set up instructions are available at SO (for example, https://stackoverflow.com/a/2275844/2303202 ) and it pretty straightforward, but it does not have any authentication and in most cases it is reasonable to use it only for reading, so you will not be able to push to the workstation, only fetch.

  3. set up ssh daemon and access through ssh authentication with read-write access. Git for windows installation contains the needed software (the sshd.exe binary, it is there at least for Git for Windows 2.6.0), probably there is a way to utilize it but I could not find it quickly.

  4. set up HTTP(S) service at your workstation. I don't know if it is possible to do only with Git for Windows (it might be, with some perl module which happen to be included with it), or you should use some other software.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM