简体   繁体   English

Git通过SSH从Raspberry Pi推送到Windows 10

[英]Git push from Raspberry Pi to Windows 10 via SSH

I come to you with a (mabye very basic) question regarding git. 我向您提出有关git的(最基本的道理)问题。

I have the following setup: 我有以下设置:

- Raspberry Pi: git respository created, added one file and commmitted it -Raspberry Pi:创建了git存储库,添加了一个文件并提交了该文件

- Windows 10 PC: git repository created, OpenSSH installed -Windows 10 PC:已创建git存储库,已安装OpenSSH

Next thing I did was testing if can access via ssh in both directions which was working fine. 我要做的下一件事是测试是否可以通过ssh双向访问,效果很好。 I could connect from my Raspberry Pi to the Windows PC via ssh using my windows username and password. 我可以使用Windows用户名和密码通过ssh从Raspberry Pi连接到Windows PC。 Now I wanted to push the one file committed on my Raspberry Pi to my repository on my windows pc. 现在,我想将在Raspberry Pi上提交的一个文件推送到Windows pc上的存储库中。 Therefore I used the following lines: 因此,我使用了以下几行:

git remote add pc ssh://Username@xxx.xxx.xxx.xxx/Projects
git push pc master

Afterwards I get asked for the password where I enter my Windows Password. 然后,我被要求在输入Windows密码的地方输入密码。 As result I get the message: 结果我得到消息:

fatal: '/Projects' does not appear to be a git repository
fatal: Could not read from remote repository

This folder '/Projects' is on my Windows PC in the directory where I get when I connect via ssh. 当通过ssh连接时,此文件夹“ / Projects”位于Windows PC上的目录中。 And if I run (locally) a "git status" in this folder I get the correct status. 如果我在此文件夹中(本地)运行“ git status”,我将获得正确的状态。

I'd would be very thankful if you can help me, especially to understand where is my thinking mistake. 如果您能帮助我,我将非常感激,尤其是了解我的思维错误在哪里。 Can I use the windows username and password for git? 我可以在git中使用Windows用户名和密码吗? Do I need an extra ssh key for git? 我需要git的额外ssh密钥吗?

Thanks in Advance! 提前致谢!

Remote git repo should be bare , so initialize it with git init --bare . 远程git repo应该是裸露的 ,因此请使用git init --bare对其进行git init --bare take a look here for explanation 在这里看看解释

确保添加绝对路径,例如/ home / user / projects

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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