Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- # run like git_update_dir.sh /my/long/folder/path/.git
- GIT_PATH="$1"
- WORK_TREE=$(echo "$GIT_PATH" | sed 's/\.git$//')
- gitexec() {
- git --git-dir="$GIT_PATH" --work-tree="$WORK_TREE" $1
- }
- echo "## UPDATE $GIT_PATH"
- if [[ "$1" == *git ]]; then
- gitexec "status"
- gitexec "reset --hard -q"
- gitexec "fetch --all -q"
- gitexec "merge --ff-only -q"
- gitexec "remote update --prune"
- # git submodule cannot work with --work-tree/--git-dir basis
- # gitexec "submodule update --init --recursive --remote"
- # gitexec "submodule foreach git reset --hard -q"
- # gitexec "submodule foreach git gc --quiet --auto"
- gitexec "gc --quiet --auto"
- else
- echo "## NOT GIT"
- fi
Add Comment
Please, Sign In to add comment