Created
October 26, 2018 02:47
-
-
Save gotraveltoworld/dcdc828f4966934070ceb29c66dc9728 to your computer and use it in GitHub Desktop.
Use 'git status' to upload files that have modified.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
local_path='Your local path' # ex: /home/your_projects/test | |
remote_path='Your cloud path' # ex: /var/www/api | |
remote_con='Your ssh connection' # ex: [email protected] | |
# Get the content in 'src/', because I only need to upload the content of 'src/' folder. | |
for file in $(git status --porcelain | grep "src/") | |
do | |
file_name=${file/'^M$'/} # Get to a Modified file. | |
local_file="$local_path$file_name" | |
remote_file="$remote_path$file_name" | |
if [ -f "$local_file" ] | |
then | |
scp $local_file $remote_con:$remote_file | |
# Show the file's name in the terminal. | |
echo "$local_file-->$remote_file" | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment