Created
September 29, 2014 11:47
-
-
Save stoivo/d0237fcb1a13a2830867 to your computer and use it in GitHub Desktop.
This is a tool to speed up git commands in terminal
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
function g { | |
# if you not in a repo STOP now | |
case $1 in | |
'' ) | |
git status | |
;; | |
'loop' ) | |
git_status_res_without_delete=$(git status | grep -v 'On branch' | grep -v 'Your branch is' | grep -v 'use "git push" to publish' | grep -v 'Changes to be committed' | grep -v 'use "git reset HEAD' | grep -v 'Changes not staged for' | grep -v 'to update what will be committed' | grep -v 'discard changes in working directory' | grep -v 'include in what will be committed' | grep -v "grep -v 'include in what will be committed'"| grep -v "git branch --unset-upstream" | grep -v "added to commit but untracked files present" | grep -v "nothing to commit, working dir" | grep -v " deleted: " | grep -v "Your branch and" | grep -v "different commits each, respectively." | grep -v "to merge the remote branch into yours)" | grep -v "You have unmerged paths" | grep -v "(fix conflicts and run " | grep -v "Unmerged paths:" | grep -v "to mark resolution)" | grep -v "renamed: ") | |
git_status_res_only_delete=$(git status | grep "deleted: " | awk '{print $2}') | |
woirking_on_new_file_for_git=0 | |
for line in $git_status_res_without_delete; do | |
if [[ $line == "modified:" ]]; then | |
continue | |
fi | |
# echo $line | |
# echo $woirking_on_new_file_for_git | |
# echo Want_to_entered | |
if [[ "$line" == "Untracked" ]]; then | |
# echo hahhahah | |
woirking_on_new_file_for_git=1 | |
fi | |
if [[ -d $line || -f $line ]]; then | |
# echo entered | |
if [[ "$woirking_on_new_file_for_git" -eq "1" ]]; then | |
# echo "$line is a regular file or directory that is new" | |
ask_user_for_action $line new | |
else | |
# echo "$line is a file ordirectory that is modifyed" | |
ask_user_for_action $line modifyed | |
fi | |
fi | |
# echo ================= | |
done | |
for file in $git_status_res_only_delete; do | |
echo "$file is removed from git" | |
read -p "what do you whant to do(rm/re(move from git), add( back),(nothing))?" yn | |
if [[ $yn == 'add' ]]; then | |
git checkout -- $file | |
elif [[ $yn == 'rm' || $yn == 're' || $yn == 'remove' ]]; then | |
git rm $file | |
fi | |
done | |
empty_if_ready_to_commit=`git status | grep 'Changes not staged for commit:\|Untracked files:\|nothing to commit, working directory clean'` | |
if [[ -z $empty_if_ready_to_commit ]]; then | |
echo "Working directory is clean, do you want to commit?" | |
read -p " enter message to commit/leave blank to continue whitout commit: " yn_pre | |
yn=`echo $yn_pre | tr -d '"'` | |
if [[ ! -z $yn ]]; then | |
echo -e git commit -m \"$yn\" | |
git commit -m "$yn" | |
fi | |
fi | |
git status | |
;; | |
GLB | Glogbranch) | |
currentBranch=$(git branch | grep "*" | awk '{print $2}') | |
echo -e "${Cyan}This is what is on $currentBranch but not on $2${NC}" | |
git log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr)%Creset' --abbrev-commit --date=relative $2..$currentBranch | |
echo -e "${Cyan}This is what is on $2 but not on $currentBranch${NC}" | |
git log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr)%Creset' --abbrev-commit --date=relative $currentBranch..$2 | |
;; | |
b | branch) | |
var=0 | |
currentBranch=$(git branch | grep "*" | awk '{print $2}' ) | |
for branch in `git branch | sed 's/^..//'`; do | |
if [[ -n $2 ]]; then | |
if [[ $2 -eq $var ]]; then | |
git checkout $branch | |
fi | |
elif [[ $var -lt 10 ]]; then | |
if [[ $branch == $currentBranch ]]; then | |
echo_ligth_blue_text " $var $branch " | |
else | |
echo " $var $branch " | |
fi | |
else | |
if [[ $branch == $currentBranch ]]; then | |
echo_ligth_blue_text "$var $branch " | |
else | |
echo "$var $branch " | |
fi | |
fi | |
var=$(($var + 1)) | |
done | |
;; | |
esac | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment