Snippets

Igor Brkic "git pull" replacement

Created by Igor Brkic
#!/bin/bash

#
# list the commits and pull the changes
#

echo Fetching...
git fetch

if [ "$?" -ne "0" ]; then
  exit $?
fi

branch=$(git branch | sed -n -e 's/^\* \(.*\)/\1/p')

output="$(git log --pretty=format:"%ad %s" --date=short --reverse ${branch}..origin/${branch})"

if [ -z "$output" ]; then
  echo No new commits.
  exit 0
fi

echo ""
echo New commits:
echo -e "$output"

echo -e ""

echo Pulling...
git pull

Comments (0)

HTTPS SSH

You can clone a snippet to your computer for local editing. Learn more.