Guest User

Untitled

a guest
Jan 19th, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. #!/bin/bash
  2. # run like git_update_dir.sh /my/long/folder/path/.git
  3.  
  4. GIT_PATH="$1"
  5. WORK_TREE=$(echo "$GIT_PATH" | sed 's/\.git$//')
  6.  
  7. gitexec() {
  8. git --git-dir="$GIT_PATH" --work-tree="$WORK_TREE" $1
  9. }
  10.  
  11. echo "## UPDATE $GIT_PATH"
  12.  
  13. if [[ "$1" == *git ]]; then
  14. gitexec "status"
  15. gitexec "reset --hard -q"
  16. gitexec "fetch --all -q"
  17. gitexec "merge --ff-only -q"
  18. gitexec "remote update --prune"
  19. # git submodule cannot work with --work-tree/--git-dir basis
  20. # gitexec "submodule update --init --recursive --remote"
  21. # gitexec "submodule foreach git reset --hard -q"
  22. # gitexec "submodule foreach git gc --quiet --auto"
  23. gitexec "gc --quiet --auto"
  24. else
  25. echo "## NOT GIT"
  26. fi
Add Comment
Please, Sign In to add comment