Created
July 12, 2017 09:12
-
-
Save hughsaunders/ec3b65a230dbd47e8020ec2921df0d5e to your computer and use it in GitHub Desktop.
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
# git push force set upstream | |
gpfsu(){ | |
branch=$(git symbolic-ref --short HEAD) | |
git push -f --set-upstream ${1:-origin} $branch | |
} | |
# git commit ammend | |
gca(){ | |
#don't want to commit accidental submodule sha changes (eg when switching branches) | |
git submodule update | |
# store old head | |
oh=$(git rev-parse HEAD) | |
git commit -a --amend --no-edit \ | |
&& git --no-pager diff HEAD@{1} \ | |
&& echo "$oh --> $(git rev-parse HEAD)" | |
} | |
# git push force | |
gpf(){ | |
git push -f $1 || gpfsu ${1:-origin} | |
} | |
# git branch contains file | |
gbcf(){ | |
regex="${1}" | |
remote="${2:-origin}" | |
git fetch "$remote" | |
for branch in $(git for-each-ref --format="%(refname)" refs/remotes/$remote/*) | |
do echo $branch | |
git ls-tree -r --name-only $branch | grep "$regex" | |
done | |
} | |
# git commit ammend push force | |
alias gcapf='gca && gpf' | |
# git remote add hugh | |
alias grah='git remote add hugh [email protected]:hughsaunders/$(basename $PWD); git remote -v' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment