54 lines
1.4 KiB
Markdown
54 lines
1.4 KiB
Markdown
---
|
|
title: "zsh git plugin"
|
|
date: 2020-01-27T12:47:22+01:00
|
|
draft: false
|
|
snippet_types: ["git", "zsh"]
|
|
---
|
|
|
|
I use git exclusive from the command line and while it's interface is very clear since I spend so
|
|
much time I'm willing to trade some of that clarity for speed. ZSH has a great plugin for really
|
|
fast git tasks. Two of my favorite are pushing while setting a upstream branch and adding patches.
|
|
|
|
**GPSUP, git set upstream and push shortcut**
|
|
|
|
I push new git branches a few times a day and my previous work flow was to:
|
|
|
|
```shell
|
|
$ gp
|
|
fatal: The current branch NOTICKET-XXX has no upstream branch.
|
|
To push the current branch and set the remote as upstream, use
|
|
|
|
git push --set-upstream origin NOTICKET-XXX
|
|
```
|
|
|
|
followed by the classic [fuck command](https://github.com/ohmyzsh/ohmyzsh/tree/master/plugins/thefuck):
|
|
|
|
```shell
|
|
$ fuck
|
|
```
|
|
|
|
which then runs the proper push command setting upstream. News flash! This call all be accomplished
|
|
with a single plugin command:
|
|
|
|
```shell
|
|
$ gpsup
|
|
```
|
|
|
|
**GAPA, git add patch**
|
|
|
|
I like small commits and the key to that for me is adding by patch. This short cut turns
|
|
|
|
```shell
|
|
$ git add --patch
|
|
```
|
|
|
|
to
|
|
|
|
|
|
```shell
|
|
$ gapa
|
|
```
|
|
|
|
Can't recommend the zsh git plugin enough! There are too many shortcut commands to be worth
|
|
memorizing but I think **gpsup** and **gapa** are worth it. For a big list of commands it checkout the docs
|
|
[here](https://github.com/ohmyzsh/ohmyzsh/tree/master/plugins/git)
|