Last active
June 10, 2016 05:50
-
-
Save nahidakbar/b24bd8f3de5f1854db32 to your computer and use it in GitHub Desktop.
Git tricks
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
# squash git commits | |
# https://wincent.com/wiki/Squashing_all_Git_commits_into_a_single_commit | |
git update-ref -d refs/heads/master | |
git commit -s -m shovel | |
#!/bin/bash | |
# Delete all containers | |
docker rm $(docker ps -a -q) | |
# Delete all images | |
docker rmi $(docker images -q) | |
# change remote | |
git remote set-url origin https://github.com/USERNAME/OTHERREPOSITORY.git | |
# speed up git gc | |
git config --global pack.threads "8" | |
git config --global pack.windowMemory "20g" | |
shovel_fcn() { | |
branch=$(git branch 2>&1) | |
branch=${branch:2:99} | |
msg=$1 | |
if [ -z $msg ] | |
then | |
msg='shovel' | |
fi | |
git status | |
git update-ref -d refs/heads/$branch | |
git commit -am "$msg" | |
git push origin $branch -f | |
git status | |
} | |
save_fcn() { | |
branch=$(git branch 2>&1) | |
branch=${branch:2:99} | |
msg=$1 | |
if [ -z $msg ] | |
then | |
msg='save' | |
fi | |
git status | |
git add . | |
git commit -am "$msg" | |
git status | |
} | |
pull_fcn() { | |
branch=$(git branch 2>&1) | |
branch=${branch:2:99} | |
git checkout $branch | |
git pull origin $branch | |
} | |
repull_fcn() { | |
branch=$(git branch 2>&1) | |
branch=${branch:2:99} | |
git fetch | |
git checkout origin/$branch | |
git branch -D $branch | |
git checkout $branch | |
} | |
push_fcn() { | |
branch=$(git branch 2>&1) | |
branch=${branch:2:99} | |
msg=$1 | |
if [ -z $msg ] | |
then | |
msg='save' | |
fi | |
git status | |
git add . | |
git commit -am "$msg" | |
git push | |
git status | |
} | |
alias pull=pull_fcn | |
alias repull=repull_fcn | |
alias save=save_fcn | |
alias push=push_fcn | |
alias shovel=shovel_fcn | |
alias debug='cmake .. -DCMAKE_BUILD_TYPE=Debug' | |
alias release='cmake .. -DCMAKE_BUILD_TYPE=Release' | |
alias gl='git status' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment