Search code examples
gitgit-ftp

git-ftp fatal: Could not get last commit. Network down? Wrong URL? Use 'git ftp init' for the inital push


I use git-ftp and works fine for days, but suddenly went broken(after few hours I upload successfully), and the debug message is:

+ 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 [email protected]
< 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...

The .git-ftp.log is still in remote, and I didn't change any variables. What's going on?


Solution

  • It turns out that my git ftp command --user has been accidentally replace to --auth, here is the error command:

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

    After I replace back the string in my git ftp command, all works again, here is the correct command:

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

    But I've read some suggest that ftp is insecure, so I replace my git ftp command to:

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

    I also change my BitBucket Pipeline YML file to use the latest php base image (php:7) instead of the older one I had originally specified (php:7.1.1)