Guest User

Untitled

a guest
Jul 18th, 2018
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. #!/bin/bash
  2. usage() {
  3. echo "usage: git dctsubmodule remove [--hard] submodulepath"
  4. }
  5.  
  6. if [[ ! -f .gitmodules ]]; then
  7. echo "git submodules not in use"
  8. exit
  9. fi
  10.  
  11. if [[ $1 != "remove" || $2 == "--help" || $2 == "" ]]; then
  12. usage
  13. exit
  14. fi
  15.  
  16. submodule=$2
  17. hard=false
  18.  
  19. if [[ $2 == "--hard" ]]; then
  20. submodule=$3
  21. hard=true
  22. fi
  23.  
  24. submodule=$( echo $submodule | sed 's/\/$//g')
  25.  
  26. git rm --cached $submodule
  27. git config --remove-section "submodule.$submodule"
  28. git config -f .gitmodules --remove-section "submodule.$submodule"
  29.  
  30. if [[ $hard == true ]]; then
  31. echo "rm -rf '$submodule'"
  32. rm -rf $submodule
  33. fi
Add Comment
Please, Sign In to add comment