Avoid git-ftp upload if files already on server

社会主义新天地 提交于 2019-12-03 17:04:39

问题


Let's say I have a local copy of my app and I push it to github and then use git-ftp to upload any changes to my server.

I would first use:

$ git ftp init -u <user> -p - ftp://host.example.com/public_html

which would upload all my files to the server and use git push for future uploads, right?

But what if I already have a copy on my server and want to set it up locally? I tried downloading my app files, used git init, pushed everything to github and then when I tried using git ftp push I received this error:

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

Then I used the git ftp init command and it worked, but it re-uploaded everything.

Is there any way to set this up without having to re-upload everything and just start using git ftp push?


回答1:


From the man page for 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.

So, if you're positive your git repository is in sync with the FTP server, run git ftp catchup in place of git ftp init the first time and it will upload the current commit hash to the server but not change any files. After that point, use git ftp push to sync future commits with it.



来源:https://stackoverflow.com/questions/13205032/avoid-git-ftp-upload-if-files-already-on-server

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!