devroom.io/content/posts/2013-03-08-review-commits-in-your-feature-branch.md

47 lines
1.4 KiB
Markdown
Raw Normal View History

2015-03-26 11:28:08 +00:00
+++
date = "2013-03-08"
title = "Review commits in your feature branch"
tags = ["git", "github", "hub"]
description = "A small shell trick to quickly see the commits that you'llsend out on a pull request from your console."
slug = "review-commits-in-your-feature-branch"
+++
2017-03-20 15:35:19 +00:00
2015-03-26 11:28:08 +00:00
Github pull requests are awesome, but you can't use them all the time, mostly when working on code not hosted at github.
The following snippet makes it easy to see the commits in your current (head) branch that are not yet in the base branch.
To see what commits are made in your current feature branch, but which have not been merged into develop yet:
2017-03-20 15:35:19 +00:00
``` shell
$ gpr develop
* 5246248 <ariejan@ariejan.net> (HEAD, origin/feature-branch, feature-branch) Implements the awesome feature (50 minutes ago)
* 4f55b7c <ariejan@ariejan.net> Write specs for awesome feature (2 hours ago)
```
2015-03-26 11:28:08 +00:00
## Snippets
To achieve this, add the following alias to `~/.gitconfig`:
2017-03-20 15:35:19 +00:00
``` ini
[alias]
lg = log --graph --pretty=format:'%Cred%h%Creset %Cblue<%ae>%C(yellow)%d%Creset %s %Cgreen(%cr)%Creset' --abbrev-commit --date=relative
```
2015-03-26 11:28:08 +00:00
And the following alias to your `~/.bashrc` or `~/.zshrc`:
2017-03-20 15:35:19 +00:00
``` shell
alias gpr="git --no-pager lg HEAD --not $1"
```
2015-03-26 11:28:08 +00:00
## Bonus tip
After reviewing the commits in your feature branch with `gpr`, use [`hub`][hub] to attach your code to a github issue:
2017-03-20 15:35:19 +00:00
``` shell
hub pull-request -i 42 -h ariejan:feature-branch -b you:develop
```
2015-03-26 11:28:08 +00:00
[hub]: http://defunkt.io/hub/