An open API service indexing awesome lists of open source software.

https://github.com/codebytere/git-fns

My personal collection of custom git functions.
https://github.com/codebytere/git-fns

Last synced: 9 months ago
JSON representation

My personal collection of custom git functions.

Awesome Lists containing this project

README

          

# Git Functions

My personal collection of custom git functions.

## Usage

In order for you to effectively make use of this repository, you'll need to clone down
its contents and ensure that they are in your `PATH`.

**Nota Bene:** I keep this in my home directory, but you can put in anywhere
so long as it's added to your `PATH` accordingly.

```sh
$ cd $HOME
$ git clone https://github.com/codebytere/git-fns
$ export PATH=$PATH:$HOME/git-fns/fns
```

## Functions

### `git patch-out [-l|--location=] [-n|--name=] [-a|--append]`

* `-l|--location=` - The location on disk where the file will be created. Defaults to `$HOME/Desktop`.
* `-n|--name=` - The name of the file to create or append to. Defaults to `local_diff`.
* `-a|--append` - Append to the file instead of overwriting it.

Allow a user to quickly export a diff in patch format to a file at a chosen location. Defaults to a file named `local_diff` created at `$HOME/Desktop`.

Example:
```sh
electron on git:master ❯ git patch-out -l=$HOME/Downloads --append
```

### `git tack [-f|--filepath=]`

* `-f|--filepath=` - The path to the file to stage and add to the last commit.

A quick way to add a forgotten change to the most recent commit in a branch without needing to create a new one for a trivial change. Automatically pushes to the current working branch.

Example:
```sh
electron on git:master ❯ git tack README.md
```

### `git refresh [-r|remote=] [-b|--branch=]`

* `-r|remote=` - The name of the git remote. Defaults to `origin`.
* `-b|--branch=` - The name of the remote branch to rebase against. Defaults to `master`.

Cleanly rebase a local working branch on a remote branch.

Example:
```sh
electron on git:master ❯ git refresh -r=codebytere -b=testing
```

### `git patch-apply [-u|--url=]`

* `-u|--url=` - The url for the commit to apply to your current working branch.

Apply a patch from a remote commit url to your current working branch.

Example:
```sh
electron on git:master ❯ git patch-apply https://github.com/electron/electron/commit/d2a82dbd1d2bd3869f910dd563001b98b3cec736
```

### `git sync [-u|--upstream=] [-o|--origin=]`

* `-u|--upstream=` - The name of the upstream git remote. Defaults to `upstream`.
* `-o|--origin=` - The name of the origin git remote. Defaults to `origin`.

Fetch latest commits from an upstream branch and update your origin
with those commits.

Example:
```sh
electron on git:master ❯ git sync
```

## Manpages

I've also included custom man pages for each of these new functions, which will need to be
added to your `MANPATH` in order to work properly.

Assuming you have already cloned down the directory as directed above:

```sh
$ cd $HOME
$ export MANPATH=$MANPATH:$HOME/git-fns/man
```

You will then be able to run:

```sh
# Or any other custom function.
$ man git-tack
```

to see:

```sh
man(1) git tack man page man(1)

NAME
git tack - Add a forgotten change to the most recent commit in a
branch.
SYNOPSIS
git tack [-f|--filepath=]

DESCRIPTION
A quick way to add a forgotten change to the most recent commit in a
branch without needing to create a new commit. Automatically pushes to
the current branch.

OPTIONS
[-f|--filepath=]
The path to the file to stage and add to the last commit.

BUGS
No known bugs.

AUTHOR
Shelley Vohr

1.0 November 2019 man(1)
```