Last active
February 19, 2019 22:32
-
-
Save adam-edison/d7e00bc9e77b46eed1aabbbe5c7dac68 to your computer and use it in GitHub Desktop.
Useful bash functions for GitLab or Git
This file contains hidden or 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
# Persist default (id_rsa) ssh key in a service that will serve this key when asked for any ssh key | |
eval `ssh-agent` | |
ssh-add | |
# Persist a specific ssh key in a service that will serve this key when asked for any ssh key | |
# eval `ssh-agent` | |
# ssh-add site_rsa | |
# Allow npp to edit anything from git bash using npp <filename> | |
alias npp="/c/Program\ Files/Notepad++/notepad++.exe" | |
# Git aliases/functions for GitLab usage | |
# update local repository with status of all branches, then list branches found locally no longer on remote (deleted or merged) | |
# delete those local branches which do not appear on the remote | |
# BE CAREFUL: local "experimental" branches will be deleted | |
local_branch_cleanup () { | |
git fetch --all -p; git branch -vv | grep ": gone]" | awk '{ print $1 }' | xargs -n 1 git branch -d | |
} | |
# shows what will be removed if you were to run local_branch_cleanup | |
local_branch_cleanup_test () { | |
git fetch --all -p; git branch -vv | grep ": gone]" | awk '{ print $1 }' | |
} | |
issue_done () { | |
git checkout master | |
git fetch -p | |
git pull | |
local_branch_cleanup | |
} | |
branch_by_issue_number () { | |
echo $(git branch -r | grep $1 | awk -F'/' '{print $2}') | |
} | |
remote_branch() { | |
git checkout master | |
git fetch -p | |
git pull | |
branch=$(branch_by_issue_number $1) | |
git checkout -b $branch origin/$branch | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment