aliases: Introduce git_parent and associated rebase aliases
This commit is contained in:
		@@ -90,6 +90,28 @@ alias cont='git rebase --continue'
 | 
				
			|||||||
alias branch_clean='git branch --merged | egrep -v "(^\*|master|dev)" | xargs git branch -d'
 | 
					alias branch_clean='git branch --merged | egrep -v "(^\*|master|dev)" | xargs git branch -d'
 | 
				
			||||||
alias tag_clean='git tag -l | xargs git tag -d && git fetch -t'
 | 
					alias tag_clean='git tag -l | xargs git tag -d && git fetch -t'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					function git_parent {
 | 
				
			||||||
 | 
					  git log --pretty=format:"%D"                | \
 | 
				
			||||||
 | 
					    grep -v "^$"                              | \
 | 
				
			||||||
 | 
					    sed "s/, /\n/g"                           | \
 | 
				
			||||||
 | 
					    grep -v "HEAD"                            | \
 | 
				
			||||||
 | 
					    grep -v `git rev-parse --abbrev-ref HEAD` | \
 | 
				
			||||||
 | 
					    grep -v "tag"                             | \
 | 
				
			||||||
 | 
					    head -n1                                  | \
 | 
				
			||||||
 | 
					    sed "s/origin\/\([^,]*\)/\1/"
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					function git_parent_tag {
 | 
				
			||||||
 | 
					  git log --pretty=format:"%D"                | \
 | 
				
			||||||
 | 
					    grep -v "^$"                              | \
 | 
				
			||||||
 | 
					    sed "s/, /\n/g"                           | \
 | 
				
			||||||
 | 
					    grep -v "HEAD"                            | \
 | 
				
			||||||
 | 
					    grep -v `git rev-parse --abbrev-ref HEAD` | \
 | 
				
			||||||
 | 
					    head -n1                                  | \
 | 
				
			||||||
 | 
					    sed "s/origin\/\([^,]*\)/\1/"             | \
 | 
				
			||||||
 | 
					    sed "s/tag: \([^,]*\)/\1/"
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
alias log='git log --graph --decorate --oneline'
 | 
					alias log='git log --graph --decorate --oneline'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Branch
 | 
					# Branch
 | 
				
			||||||
@@ -138,18 +160,46 @@ function grbm {
 | 
				
			|||||||
  git rebase --interactive master
 | 
					  git rebase --interactive master
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function grbr {
 | 
					function grbi {
 | 
				
			||||||
 | 
					  # Save current branch
 | 
				
			||||||
 | 
					  BRANCH=$(git branch | grep \* | cut -d ' ' -f2)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  # Save parent branch
 | 
				
			||||||
 | 
					  PARENT=$(git_parent)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  # Checkout parent & pull
 | 
				
			||||||
 | 
					  git checkout ${PARENT}
 | 
				
			||||||
 | 
					  git pull
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  echo "Rebasing on ${PARENT}"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  # Back to previous branch
 | 
				
			||||||
 | 
					  git checkout ${BRANCH}
 | 
				
			||||||
 | 
					  git rebase --interactive ${PARENT}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					function grbroot {
 | 
				
			||||||
  git rebase --interactive --autosquash --root
 | 
					  git rebase --interactive --autosquash --root
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					function ga {
 | 
				
			||||||
 | 
					  git autofixup HEAD~$1
 | 
				
			||||||
 | 
					  git rebase --interactive --autosquash HEAD~$1
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function gam {
 | 
					function gam {
 | 
				
			||||||
  git autofixup master
 | 
					  git autofixup master
 | 
				
			||||||
  git rebase --interactive --autosquash master
 | 
					  git rebase --interactive --autosquash master
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function ga {
 | 
					function gai {
 | 
				
			||||||
  git autofixup HEAD~$1
 | 
					  # Save parent branch
 | 
				
			||||||
  git rebase --interactive --autosquash HEAD~$1
 | 
					  PARENT=$(git_parent)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  echo "Rebasing with autofixup on ${PARENT}"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  git autofixup ${PARENT}
 | 
				
			||||||
 | 
					  git rebase --interactive --autosquash ${PARENT}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# ╔═╗┬┌┬┐  ╔═╗┌┬┐┌─┐┌┐┌┌┬┐
 | 
					# ╔═╗┬┌┬┐  ╔═╗┌┬┐┌─┐┌┐┌┌┬┐
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user