Skip to content

Instantly share code, notes, and snippets.

@mnadjit
Created June 18, 2023 13:05
Show Gist options
  • Save mnadjit/c1df8d529cb90d6624a81e627771bf02 to your computer and use it in GitHub Desktop.
Save mnadjit/c1df8d529cb90d6624a81e627771bf02 to your computer and use it in GitHub Desktop.
Shell scripts to upload or download contents of the directory passed as arguments
#!/usr/bin/bash
if [ "$#" -eq 0 ]; then
echo $'No paths were passed to the script.\nScript usage:\n> ./load /path/to/dir1 /path/to/dir2'
fi
for path in "$@"
do
echo -e "\n\ngit fetch, reset and pull for path: $path\n"
cd $path
git fetch origin main
git reset --hard origin/main
git pull --force
done
#!/usr/bin/bash
if [ "$#" -eq 0 ]; then
echo $'No paths were passed to the script.\nScript usage:\n> ./save /path/to/dir1 /path/to/dir2'
fi
for path in "$@"
do
echo -e "\n\ngit add, commit and push for path: $path\n"
cd $path
git add --all
git commit -m "update"
git push --force
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment