尝试通过 scp 复制我的存储库时,我突然收到一个 Permission Denied (the contents of .git/objects files) 错误
I suddenly get a Permission Denied (the contents of .git/objects files) error when trying to copy my repository via scp
所以我对 git 和 ssh 都是新手,所以我所说的一些基本术语可能是错误的。
我正在尝试复制(使用 scp
)我的存储库(我还通过 github 备份了这个存储库,所以它有一个 .git
文件夹)到远程机器我通过 ssh 访问。
以前一直有效。
然后我从 master
添加了另一个分支,并继续在该新分支上编写代码。
我不知道我更改的任何其他内容可能对此处很重要。
无论如何,现在用于将存储库复制到远程计算机的旧 scp -r
命令上传我的普通文件,但它在“.git/objects
”中失败:
scp: /scratch/petzi/remote/meins/.git/objects/43/50c1b2c7306710fad08153c12fd4a394aef0fc:
Permission denied
以及“objects
”中各种文件(甚至可能是所有文件,我没有检查过)的等效消息。
我怎样才能克服这些错误消息?
不使用 scp,而是复制每个文件,use git bundle
,并且 scp 仅 一个 文件。错误更少。
cd /path/to/local/myrepo
git bundle create ../myrepo.bundle --all
scp ../myrepo.bundle remoteUser@remoteServer:~/myrepo.bundle
在远程服务器上:
cd /path/to/myrepo
git remote add bundle /home/remoteUser/myrepo.bundle
git fetch bundle
git switch master
git merge bundle/master
您可以从捆绑包中克隆或获取,捆绑包(同样)是 一个 代表您的存储库的文件。
为什么你每次 scp -r
完整的存储库? Git 已经被开发用来在多台机器之间同步代码,但是你正在使用 scp
做它(尽管你正在使用 git)。
如果您想在两台机器之间保持代码同步,并且您在 github 中已经有一个 git 存储库,那么只需使用 github 存储库作为规范存储库即可同步您的机器。
假设您在远程计算机 中已经有一个 git 存储库。
在您的本地计算机上进行更改后:
- 提交您的代码
- 将您的代码推送到 github(类似于
git push origin master
)
ssh
到你的机器
cd
到 git 存储库路径
- 从 github(类似于
git pull origin master
)获取您的代码
所以我对 git 和 ssh 都是新手,所以我所说的一些基本术语可能是错误的。
我正在尝试复制(使用 scp
)我的存储库(我还通过 github 备份了这个存储库,所以它有一个 .git
文件夹)到远程机器我通过 ssh 访问。
以前一直有效。
然后我从 master
添加了另一个分支,并继续在该新分支上编写代码。
我不知道我更改的任何其他内容可能对此处很重要。
无论如何,现在用于将存储库复制到远程计算机的旧 scp -r
命令上传我的普通文件,但它在“.git/objects
”中失败:
scp: /scratch/petzi/remote/meins/.git/objects/43/50c1b2c7306710fad08153c12fd4a394aef0fc:
Permission denied
以及“objects
”中各种文件(甚至可能是所有文件,我没有检查过)的等效消息。
我怎样才能克服这些错误消息?
不使用 scp,而是复制每个文件,use git bundle
,并且 scp 仅 一个 文件。错误更少。
cd /path/to/local/myrepo
git bundle create ../myrepo.bundle --all
scp ../myrepo.bundle remoteUser@remoteServer:~/myrepo.bundle
在远程服务器上:
cd /path/to/myrepo
git remote add bundle /home/remoteUser/myrepo.bundle
git fetch bundle
git switch master
git merge bundle/master
您可以从捆绑包中克隆或获取,捆绑包(同样)是 一个 代表您的存储库的文件。
为什么你每次 scp -r
完整的存储库? Git 已经被开发用来在多台机器之间同步代码,但是你正在使用 scp
做它(尽管你正在使用 git)。
如果您想在两台机器之间保持代码同步,并且您在 github 中已经有一个 git 存储库,那么只需使用 github 存储库作为规范存储库即可同步您的机器。
假设您在远程计算机 中已经有一个 git 存储库。 在您的本地计算机上进行更改后:
- 提交您的代码
- 将您的代码推送到 github(类似于
git push origin master
) ssh
到你的机器cd
到 git 存储库路径- 从 github(类似于
git pull origin master
)获取您的代码