Advertisement
rdsedmundo

push.sh (2)

Nov 23rd, 2016
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.81 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. git add .;
  4. git commit -m "$1";
  5.  
  6. STAGED_FILES=$(git diff --name-status --staged);
  7.  
  8. while read -r FILE; do
  9.     STATUS=${FILE:0:1};
  10.     FILENAME=${FILE:2};
  11.  
  12.     if [ "$STATUS" == "M" ] || [ "$STATUS" == "A" ]
  13.     then
  14.         echo "... copying file: ../pathto/$FILENAME";
  15.         cp -r $FILENAME ../pathto/$FILENAME;
  16.     elif [ "$STATUS" == "R" ]
  17.     then
  18.         echo "... removing file: ../pathto/$FILENAME";
  19.         rm -r $FILENAME ../pathto/$FILENAME;
  20.     else
  21.         echo "Fatal error: $STATUS not tracked";
  22.         exit;
  23.     fi;
  24. done <<< "$STAGED_FILES";
  25.  
  26. echo "Pushing to Bitbucket:";
  27.  
  28. cd ../pathto/;
  29. git add .;
  30. git config user.name ""
  31. git config user.email ""
  32. git commit -m "$1";
  33. git push origin master;
  34.  
  35. echo "Pushing to Github:";
  36. cd ../pathto/;
  37. git push origin master;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement