From 60411b9c7f37ae8f8f962d37d4a4d3753e5eb47f Mon Sep 17 00:00:00 2001 From: Sameer Rahmani Date: Mon, 18 Jul 2022 18:19:11 +0100 Subject: [PATCH] Add more git helper functions for diffing branches --- aliases/common.alias | 4 ++-- lib/git.zsh | 12 ++++++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/aliases/common.alias b/aliases/common.alias index 6156958..78c2690 100644 --- a/aliases/common.alias +++ b/aliases/common.alias @@ -47,8 +47,8 @@ alias ll='ls -lh' alias la='ls -lhA' alias sl=ls -alias ...='cd ../..' -alias ....='cd ../../..' +#alias ...='cd ../..' +#alias ....='cd ../../..' alias _="sudo" alias Ps="ps aux|grep --color" diff --git a/lib/git.zsh b/lib/git.zsh index 5820634..bed17df 100755 --- a/lib/git.zsh +++ b/lib/git.zsh @@ -128,11 +128,11 @@ function git_compare_version() { } function git_current_branch() { - git branch |grep "*"|cut -d ' ' -f 2 + git branch --show-current } function git_push() { - git push origin `git_current_branch` + git push origin `git_current_branch` "$@" } function git_pull() { @@ -147,6 +147,14 @@ function git_changed_files_since_master() { git_changed_files $(git_current_branch) master } +function git_commits_from() { + git log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr)%Creset' --abbrev-commit --date=relative $1..$(git branch --show-current) +} + +function reset_branch_commits() { + git reset $(git merge-base $1 $(git branch --show-current)) +} + #this is unlikely to change so make it all statically assigned POST_1_7_2_GIT=$(git_compare_version "1.7.2") #clean up the namespace slightly by removing the checker function