大家好![](https://zoearth1024moon99nas.direct.quickconnect.to/plugins/editors-xtd/zoearth_insert_emoticons_btn/imgs/756d.gif)
![](https://zoearth1024moon99nas.direct.quickconnect.to/plugins/editors-xtd/zoearth_insert_emoticons_btn/imgs/756d.gif)
最近遇到一些情況
必須使用 git ftp
應該說...之前應該就要用 但是遲遲未使用 ![](https://zoearth1024moon99nas.direct.quickconnect.to/plugins/editors-xtd/zoearth_insert_emoticons_btn/imgs/5ff6.gif)
![](https://zoearth1024moon99nas.direct.quickconnect.to/plugins/editors-xtd/zoearth_insert_emoticons_btn/imgs/5ff6.gif)
如果不使用 git ftp
就必須在遠端環境上配置 git 環境
或是 遠端環境支援 git 發布
類似 heroku 那樣,會直接同步最新分支...
但是通常建置這樣環境成本很高
老闆通常也沒這美國時間等你... 或是 根本無法理解你的問題
所以我發現使用 git ftp 似乎是最好選擇...
環境就只需要 FTP 就可以了
相當單純
然後我有找到一篇文章
install and configure git-ftp on windows OS with easy step by step guide
http://www.codingsips.com/install-configure-git-ftp-windows/
這篇文章是我看一些文章中說得最清楚的
以下列出步驟
1. 開發環境安裝GIT 與 要被放程式的主機必須有 FTP,且FTP帳號登入後必須就是 git 專案的目錄
這邊並不是FTP那邊會使用到 .git 這資料夾的因素,而是要確保git ftp 進去後的位置跟開發端資料夾必須是一樣的,其實FTP端也可以是空的
2. 開發端開啟 git bash 切換到 git 安裝資料夾 (這邊可能有差異,須注意 git 安裝在哪邊)
cd /c/"Program Files"/Git
3. 複製 git-ftp 專案下來
git clone https://github.com/git-ftp/git-ftp git-ftp.git
4. 進入 git-ftp.git 資料夾 與 修改 git-ftp 的可執行屬性
cd git-ftp.git && chmod +x git-ftp
5. 取得目前 git 的實際執行路徑
//我這邊產生的是 C:/Program Files/Git/mingw64/libexec/git-core
git --exec-path
5. 複製 剛剛已經修改可執行的 git-ftp 到 C:/Program Files/Git/mingw64/libexec/git-core 裡面
cp /c/"Program Files"/Git/git-ftp.git/git-ftp /c/"Program Files"/Git/mingw64/libexec/git-core
複製完之後確認是否有 git-ftp 檔案了
6. 有檔案後 打指令 git ftp 看看有沒有反應
如果發生 找不到指令錯誤,那表示 git 的執行路徑裡面還是沒有可執行的 git-ftp
7. 配置 git ftp ,,到 專案資料夾底下打開 git bash
8. 然後 輸入設定
git config git-ftp.url ftp://你的FTP位置 git config git-ftp.user FTP帳號 git config git-ftp.password FTP密碼
9. 輸入 git ftp init 來起始第一次上傳FTP (FTP全部檔案檢查一次的意思)
之後就使用 git ftp push 來推送目前分支囉 (注意目前專案分支)
題外話:
這次配置中我還遇到中文檔案名稱無法上傳問題![](https://zoearth1024moon99nas.direct.quickconnect.to/plugins/editors-xtd/zoearth_insert_emoticons_btn/imgs/35c9.gif)
![](https://zoearth1024moon99nas.direct.quickconnect.to/plugins/editors-xtd/zoearth_insert_emoticons_btn/imgs/35c9.gif)
當然,這些中文檔案是專案討論或規劃的文件
確實程式用不到
所以我們還可以使用
.git-ftp-ignore 檔案
來忽略git ftp 上傳時的檔案
裡面可以打上要忽略的資料夾
例如這樣
/系統規劃/* 系統規劃/*
給大家參考囉
感恩![](https://zoearth1024moon99nas.direct.quickconnect.to/plugins/editors-xtd/zoearth_insert_emoticons_btn/imgs/756d.gif)
![](https://zoearth1024moon99nas.direct.quickconnect.to/plugins/editors-xtd/zoearth_insert_emoticons_btn/imgs/756d.gif)
留言板
歡迎留下建議與分享!希望一起交流!感恩!