Last active
January 24, 2017 20:18
-
-
Save alexcameron89/e6eff5dc8e09b4c1ebe7e0bca9c060be to your computer and use it in GitHub Desktop.
Git Pull Bash function
This file contains 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
# gp remembers the last commit before pulling, pulls the repository and logs | |
# all the commits oldest to newest along with their changes. | |
gp () { | |
# The last variable therefore stores the most recent commit's hash. | |
# | |
# What's Going on: | |
# git log --oneline prints a commit log on one line: | |
# b9bda7f Allocation free Integer#to_s | |
# git log -n 1 outputs only one commit, defaulting to the most recent commit. | |
# The log result is piped to awk which grabs the first leftmost column which | |
# is the commit hash. | |
last=$(git log --oneline -n 1 | awk '{print $1;}') | |
git pull | |
# git log -p stands for "patch" and shows the changes made in the commit. | |
# git log --reverse shows sorts by oldest commit first. | |
# $last..HEAD says "show me everything since the $last commit, excluding it. | |
git log -p --reverse $last..HEAD | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment