Skip to content

Instantly share code, notes, and snippets.

@gongzhitaao
Last active March 7, 2017 14:18
Show Gist options
  • Save gongzhitaao/f74188d62542110ef931005ae0325bc9 to your computer and use it in GitHub Desktop.
Save gongzhitaao/f74188d62542110ef931005ae0325bc9 to your computer and use it in GitHub Desktop.
Sync local folder with remote folder.

This Makefile sync current local working folder with the remote folder.

When working on a server, I always want to edit files locally and then push them to servers to run. However I do not want to track what files I just changed and push them one by one using SFTP. rsync solves this issue elegantly.

Concretely, when I'm finishing editing files locally, I just type

make

the changed files will be synced to remote folers. Whenever I want to fetch result from remote folders

make get

include-get.txt and include-put.txt controls what files I want to push to and fetch from servers. Refer to rsync manuals for details.

local := $(CURDIR)/
# remote := lab:/home/zzg0009/Documents/paper-adv/
remote := k80:/home/zzg0009/workspace/paper-adv/
put :
rsync -abvzhL \
--include-from='include-put.txt' \
--exclude='*' \
$(local) $(remote)
get :
rsync -abvzh \
--include-from='include-get.txt' \
--exclude='*' \
$(remote) $(local)
clean :
rm *~
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment