Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/ssh/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
git通过ssh添加文件_Git_Ssh - Fatal编程技术网

git通过ssh添加文件

git通过ssh添加文件,git,ssh,Git,Ssh,我在Ubuntu机器上编程,希望在Mac上备份 使用从Mac登录到Ubuntu ssh myubuntu@xx.dyndns.org 很好 这是我想在Mac上执行的操作(将.c文件添加到Mac git): 但第一个命令会导致错误: fatal: pathspec ‘myubuntu@xx.dyndns.org/home/myubuntu/Documents/*.c’ did not match any files 我应该如何重新表述git add命令?假设您已经在Mac上安装了git,并且U

我在Ubuntu机器上编程,希望在Mac上备份

使用从Mac登录到Ubuntu

ssh myubuntu@xx.dyndns.org
很好

这是我想在Mac上执行的操作(将.c文件添加到Mac git):

但第一个命令会导致错误:

fatal: pathspec ‘myubuntu@xx.dyndns.org/home/myubuntu/Documents/*.c’ did not match any files

我应该如何重新表述git add命令?

假设您已经在Mac上安装了git,并且Ubuntu机器的git repo的根目录是
/home/myubuntu/Documents

git clone myubuntu@xx.dyndns.org:/home/myubuntu/Documents myproj
然后,每次你想备份到你的Mac电脑时,在Mac电脑上只需执行
git pull

如果您尚未将Ubuntu文件放入Git,请在该计算机上执行以下操作:

cd /home/myubuntu/Documents
git init
git add .
git commit

仅供参考,这会将所有子文件夹中的所有文件添加到存储库中,这可能不是您想要的。

git add适用于本地文件。如果您试图在mac上获取回购协议的副本,您需要使用git clone。
git add
不进行复制。您希望有两个不同的存储库,并使用
fetch
pull
push
同步它们。如果您希望备份代码,只需获得一个GitHub或Bitbucket帐户。他们的存储可能比你们的两台个人电脑安全得多。代码所有者不允许在互联网上存储。Mac是自动备份的。在
git init
之后,您忘记了
git add.
,否则就没有要提交的内容了。啊,是的,您是对的。我忘记了
-a
开关不能拾取新文件。
cd /home/myubuntu/Documents
git init
git add .
git commit