假设我有我的应用程序的本地副本,我将其推送到 github,然后使用 git-ftp 将任何更改上传到我的服务器。
我会首先使用:
$ git ftp init -u <user> -p - ftp://host.example.com/public_html
这会将我所有的文件上传到服务器并使用 git push
进行 future 的上传,对吗?
但是,如果我的服务器上已有一个副本并想在本地设置它怎么办?我尝试下载我的应用程序文件,使用 git init
,将所有内容推送到 github,然后当我尝试使用 git ftp push
时,我收到了这个错误:
fatal: Could not get last commit. Network down? Wrong URL? Use 'git ftp init' for the inital push., exiting...
然后我使用了 git ftp init
命令,它起作用了,但它重新上传了所有内容。
有什么方法可以设置它而不必重新上传所有内容并开始使用 git ftp push
吗?
最佳答案
来自 git-ftp
的手册页:
catchup
Uploads current SHA1 to log, does not upload any files.
This is useful if you used another FTP client to upload the
files and now want to remember the SHA1.
因此,如果您确定您的 git 存储库与 FTP 服务器同步,请第一次运行 git ftp catchup
代替 git ftp init
会将当前的提交哈希上传到服务器,但不会更改任何文件。之后,使用 git ftp push
与它同步 future 的提交。
关于git - 如果文件已经在服务器上,避免 git-ftp 上传,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13205032/