Guest User

Untitled

a guest
Jul 21st, 2018
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.43 KB | None | 0 0
  1. #!/usr/bin/env bash
  2.  
  3. : "
  4. # Git updater for Linux
  5. # Author: Rakibul Yeasin (fb.com/rytotul)
  6. "
  7.  
  8. function main {
  9. echo
  10. echo "[*] Done...Initializing who am I."
  11. git config user.email "email@email.com"
  12. git config user.name "User"
  13.  
  14. # Check whether it is already a git repo or not
  15. if [[ -e ".git" ]]; then
  16. echo "[*] Already a git repo..."
  17. else
  18. echo "[*] Done...Initializing a new Git repo for this project."
  19. echo
  20. git init
  21. fi
  22.  
  23. # Add new files if there any
  24. echo
  25. echo "[*] Done...Saving changes to the repository."
  26. git add .
  27.  
  28. # Commit Changes
  29. # TO HACK COMMIT JUST COMMENT OUT #1 AND PLACE YOUR COMMIT INSTEAD OF $message
  30. echo "[*] Done...Committing a modified version of a file to the repo."
  31. echo
  32. read -p "[*] Add commit message: " message #1
  33. git commit -am "$message"
  34.  
  35. # List your existing remotes in order to get the name of the remote you want to change.
  36. echo
  37. echo "[*] Checking remote origin."
  38. repo=$(git remote -v)
  39.  
  40. # Checks the repository avaibility
  41. if [[ $repo == "" ]]; then
  42. echo -e "[-] No remote repository added.\n[-] Add Some..."
  43. else
  44. echo "[*] Remote repository found!"
  45. fi
  46.  
  47. # Push the local changes to remote
  48. echo
  49. echo "[*] Pushing local codebase to remote repo...Repo-to-repo collaboration."
  50. #git push origin master
  51. git push --all -f
  52. }
  53.  
  54. function update {
  55. # List your existing remotes in order to get the name of the remote you want to change.
  56. echo
  57. echo "[*] Checking remote origin."
  58. repo=$(git remote -v)
  59.  
  60. # Changes the remote's URL.
  61. echo
  62. read -p "[+] The new repo URL: " n_repo
  63. echo "[*] Done...Updating remote URL."
  64. git remote set-url origin $n_repo
  65.  
  66. # Verify that the remote URL has changed.
  67. echo "[*] Done...Verifying remote URL."
  68. repo2=$(git remote -v)
  69. if [[ $repo == $repo2 ]]; then
  70. echo -e "[*] Repo's are same...\n"
  71. else
  72. echo -e "[*] Repo Updated!\n"
  73. fi
  74. }
  75.  
  76. # Help Message
  77. function help {
  78. echo "[+] Pass 'u' as an argument to update the remote URL"
  79. echo "[+] Pass 'h' or '-h' for 'help'"
  80. echo "[+] TO HACK COMMIT JUST COMMENT OUT #1 AND PLACE YOUR COMMIT INSTEAD OF $message"
  81. }
  82.  
  83. # Here the Scripts Starts
  84. if [[ $1 == 'h' || $1 == '-h' ]]; then
  85. help
  86. elif [[ $1 == "u" ]]; then
  87. update
  88. elif [[ $1 == "" ]]; then
  89. main
  90. else
  91. echo "[-] Nothing Understood..."
  92. echo "[-] Pass 'h' for 'Help'"
  93. fi
Add Comment
Please, Sign In to add comment