## 1.安裝Homebrew
```
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
```
## 2.將SSH KEY公鑰添加到Linux服務器
```
方法一:
brew install ssh-copy-id
ssh-copy-id -i ~/.ssh/id_rsa.pub root@Linux服務器IP
方法二:
cat ~/.ssh/id_rsa.pub, 獲取公鑰
然后在Linux服務器上,編輯文件 vim ~/.ssh/authorized_keys,將公鑰添加進去并保存
```
## 3.安裝fswatch
```
brew install fswatch
```
## 4.編輯自動上傳配置文件
```
sudo vim /mac-auto-deploy (編輯目錄可自定義)
```
輸入下在的內容:
```shell
#======
#!/bin/sh
local=$1
remote=$2
cd "$local" &&
fswatch . |xargs -n1 -I{} rsync -aztH --exclude .git --exclude .sass-cache --exclude .idea --delete --progress --rsh='ssh -l root -p22' . $remote
#======
```
## 5.在本地項目根目錄中執行此命令
```
/mac-auto-deploy . root@Linux服務器IP:Linux服務器項目路徑
```