Skip to content

Instantly share code, notes, and snippets.

@JarJak
Last active June 1, 2022 09:26
Show Gist options
  • Save JarJak/407e99ccf152f9f560db5278112ca7cb to your computer and use it in GitHub Desktop.
Save JarJak/407e99ccf152f9f560db5278112ca7cb to your computer and use it in GitHub Desktop.
Useful GIT bash aliases
eval $(docker-machine env)
SSH_ENV=$HOME/.ssh/environment
force_color_prompt=yes
source /Library/Developer/CommandLineTools/usr/share/git-core/git-prompt.sh
PS1="\[\033[1;36m\]\u\[\033[1;35m\]@\[\033[1;34m\]#:\[\033[1;33m\]\w\[\033[1;32m\]\$(__git_ps1) \[\033[1;31m\]\$ \[\033[00m\]"
alias ls='ls --color=auto'
alias grep='grep --color=auto'
# start the ssh-agent
function start_agent {
echo "Initializing new SSH agent..."
# spawn ssh-agent
/usr/bin/ssh-agent | sed 's/^echo/#echo/' > "${SSH_ENV}"
echo succeeded
chmod 600 "${SSH_ENV}"
. "${SSH_ENV}" > /dev/null
/usr/bin/ssh-add
}
if [ -f "${SSH_ENV}" ]; then
. "${SSH_ENV}" > /dev/null
ps -ef | grep ${SSH_AGENT_PID} | grep ssh-agent$ > /dev/null || {
start_agent;
}
else
start_agent;
fi
# eval $(thefuck --alias)
GIT_BASE_BRANCH=main
function git_create_branch {
git checkout ${GIT_BASE_BRANCH} && git pull && git checkout -b $1 && git push -u origin $1
}
alias gitcb=git_create_branch
function git_create_branch_from_actual {
git checkout -b $1 && git push -u origin $1
}
alias gitcbfa=git_create_branch_from_actual
function git_quick_branch {
git add . -u && git stash && git checkout ${GIT_BASE_BRANCH} && git pull && git checkout -b $1 && git push -u origin $1 && git stash apply
}
alias gitquick=git_quick_branch
function git_quick_branch_from_actual {
git add . -u && git stash && git checkout -b $1 && git push -u origin $1 && git stash apply
}
alias gitquickfa=git_quick_branch_from_actual
function git_undo_remove_file {
git checkout $(git rev-list -n 1 HEAD -- "$1")^ -- "$1"
}
alias gitunrm=git_undo_remove_file
alias gitclean='git checkout develop && git pull && git fetch --prune && git branch --merged develop | grep -v "\* develop" | xargs -n 1 git branch -d'
function git_commit_push {
git commit -am $1 && git push
}
alias gitcp=git_commit_push
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment