首页 > 解决方案 > git-ftp 致命:无法获得最后一次提交。网络断了?错误的网址?使用 'git ftp init' 进行初始推送

问题描述

我使用 git-ftp 并且工作了好几天,但突然坏了(几个小时后我成功上传),调试消息是:

+ git ftp push -vv --syncroot folder/ --auth $USERNAME --passwd $PASSWORD $URL
Thu Dec  6 13:48:12 UTC 2018: Using syncroot folder/ if exists.
Thu Dec  6 13:48:12 UTC 2018: Host is 'myhost.com'.
Thu Dec  6 13:48:12 UTC 2018: User is ''.
Thu Dec  6 13:48:12 UTC 2018: Password is set.
Thu Dec  6 13:48:12 UTC 2018: Path is 'remote_folder/'.
Thu Dec  6 13:48:12 UTC 2018: Syncroot is 'folder/'.
Thu Dec  6 13:48:12 UTC 2018: CACert is ''.
Thu Dec  6 13:48:12 UTC 2018: Insecure is ''.
Thu Dec  6 13:48:12 UTC 2018: Retrieving last commit from ftp://myhost.com/.
* Couldn't find host myhost.com in the .netrc file; using defaults
* Hostname was NOT found in DNS cache
*   Trying ***.***.***.**...
* Connected to myhost.com (***.***.***.**) port 21 (#0)
< 220 Host FTP Server
> USER anonymous
< 331 Password required for anonymous
> PASS ftp@example.com
< 530 Login incorrect.
* Access denied: 530
* Closing connection 0
curl: (67) Access denied: 530
Thu Dec  6 13:48:15 UTC 2018: fatal: Could not get last commit. Network down? Wrong URL? Use 'git ftp init' for the inital push., exiting...

.git-ftp.log 仍在远程,我没有更改任何变量。这是怎么回事?

标签: gitgit-ftp

解决方案


原来我的 git ftp 命令--user不小心被替换成了--auth,下面是错误命令:

git ftp push -vv --syncroot folder/ --auth $USERNAME --passwd $PASSWORD $URL

在我的 git ftp 命令中替换回字符串后,一切正常,这是正确的命令:

git ftp push -vv --syncroot folder/ --user $USERNAME --passwd $PASSWORD $URL

但我读过一些关于 ftp 不安全的建议,所以我将 git ftp 命令替换为:

git ftp push -vv --key ~/.ssh/my_ssh_key --syncroot folder/ --user $USERNAME --passwd $PASSWORD sftp://myhost.com/~remote_folder/

我还更改了我的 BitBucket Pipeline YML 文件以使用最新的 php 基本映像 (php:7) 而不是我最初指定的旧的 (php:7.1.1)


推荐阅读