Skip to content

Instantly share code, notes, and snippets.

@bgotink
Forked from barijaona/._what.md
Last active December 25, 2015 06:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bgotink/6932836 to your computer and use it in GitHub Desktop.
Save bgotink/6932836 to your computer and use it in GitHub Desktop.

Badass git pull alternative

Add this in your path as git-up and git-reup (symbolic link) and it amps up your git pull by means of git up

  1. Adds in a list of the commits you're pulling down
  2. Auto-prunes remote branches
  3. Defaults to pull --rebase - gets rid of unnecessary merge commits. If you don't know what rebase does, this is probably safe for you. If you know what rebase does, you should know where this will not be safe for you.

Kyle Neath, Ryan Tomayko and then Zach Holman basically figured out how to do this. TheSpyder found a small error on case sensitive file systems.

barijaon$ git reup ViennaRSS master
From github.com:ViennaRSS/vienna-rss
* branch master -> FETCH_HEAD
First, rewinding head to replay your work on top of it...
Fast-forwarded certum-signed to 8e670959888aca0a716576650e26c23db6fa5b42.
Diffstat:
BrowserPane.m | 5 +++++
FilterView.m | 1 +
2 files changed, 6 insertions(+), 0 deletions(-)
Log:
8e67095 Merge pull request #57 from Marco-Zehe/VoiceOverFixes
035453c Fixed tab indents.
9bb2480 Merge pull request #56 from barijaona/certum-signed
4673811 Fix buttons in filter view and browser pane to have proper labels for VoiceOver. Issue #54.
#!/usr/bin/env ruby
#
# Usage: git-up
# git-reup
#
# Like git-pull but show a short and sexy log of changes
# immediately after merging (git-up) or rebasing (git-reup).
#
# Inspired by Kyle Neath's `git up' alias:
# http://gist.github.com/249223
#
# Stolen from Ryan Tomayko
# http://github.com/rtomayko/dotfiles/blob/rtomayko/bin/git-up
# and then Zach Holman
# https://github.com/holman/dotfiles/blob/master/bin/git-up
require 'shellwords'
pull_args = ARGV.to_a
rebase = File.basename($0) == 'git-reup'
stashed = false
old_head = `git rev-parse HEAD`.chomp
exit($?.to_i) unless $? == 0
if rebase
pull_args.unshift '--rebase'
msg = `git stash save "Auto-stash by #{File.basename($0)} script"`
stashed = msg !~ /^No local changes to save$/
end
system "git pull #{pull_args.shelljoin}"
updated = (old_head != `git rev-parse head`.chomp)
system "git stash pop --quiet" if stashed && rebase
if updated
if rebase
puts "Diffstat:"
system "git --no-pager diff --color --stat #{old_head}.. | sed 's/^/ /'"
end
puts "Log:"
system "git log --color --pretty=oneline --abbrev-commit #{old_head}.. | sed 's/^/ /'"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment