Last active
May 17, 2017 05:06
-
-
Save ashrafuzzaman/7dab59c52e34f4d43b102749d2966f1f to your computer and use it in GitHub Desktop.
Git scripts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
myssid=$(iwgetid -r) | |
if [[ $myssid == "NewsCred Inc" ]]; then | |
echo "In office" | |
/bin/bash -l -c '/home/jitu/Software/pycharm/bin/pycharm.sh' %f & | |
gnome-terminal --maximize --working-directory=/home/jitu/projects/marketingplatform | |
else | |
echo "Out of office" | |
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
echo "Checking out to master ..." | |
git checkout master | |
echo "Removing merged branches ..." | |
git branch --merged | grep -v "master" | xargs -n 1 git branch -d |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
branch_name="$(git symbolic-ref --short -q HEAD)" | |
echo "Force pushing" $branch_name | |
git push --force origin $branch_name |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
IFS=':' read -r -a input <<< "$1" | |
user=${input[0]} | |
branch=${input[1]} | |
git checkout master | |
git reset --hard newscred/master | |
git pull newscred master:master | |
echo "fetching $user $branch" | |
git fetch "$user" "$branch" | |
git merge "$user"/"$branch" --ff-only | |
git branch -D "$branch" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
branch=`git rev-parse --abbrev-ref --symbolic-full-name @{u}` | |
IFS='/' read -r -a input <<< "$branch" | |
remote_origin=${input[0]} | |
[ ! -z $remote_origin ] || remote_origin='origin' | |
branch_name="$(git symbolic-ref --short -q HEAD)" | |
echo "Rebasing $remote_origin/$branch_name" | |
git fetch newscred master:master && git rebase newscred/master && git push --force $remote_origin $branch_name |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
IFS=':' read -r -a input <<< "$1" | |
user=${input[0]} | |
branch=${input[1]} | |
# check if user is added in remote | |
if [[ `git remote` =~ $user ]]; then | |
echo 'Remote exists' | |
else | |
newscred_remote_url=`git remote get-url newscred` | |
user_remote_url="${newscred_remote_url/newscred/$user}" | |
echo "Adding $user as $user_remote_url" | |
git remote add $user $user_remote_url | |
fi | |
git fetch $user $branch | |
branch_exists=`git branch --list $branch` | |
if [ "$branch_exists" ]; then | |
echo "Branch already exists" | |
git checkout $branch | |
git reset --hard $user/$branch | |
else | |
echo "Checking out to new branch" | |
git checkout -t $user/$branch | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment