Pimp your git workflow. Just type pull, branch, merge, push
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.

README.md

A collection of shell scripts for making pulling, pushing, branching, merging, and stashing with Git fast and painless.

Git sometimes requires typing two or three commands just to execute something basic like fetching new code. git-friendly adds a few new commands — pull, push, branch, merge and stash which:

  • do the most useful thing by default;
  • push also copies a GitHub compare URL to your clipboard;
  • pull runs commands like bundle install, npm install, yarn install, and composer install if necessary;
  • branch tracks remote branches if they are available;
  • stash stashes untracked files by default.

Less time fighting Git — more time actually doing work.

Install

Run this one-liner, which will download the scripts into /usr/local/bin:

curl -sS https://raw.githubusercontent.com/jamiew/git-friendly/master/install.sh | bash

Note: If you don’t have write access to /usr/local/bin you’ll need to run this using sudo.

You can change the installation directory:

curl -sS https://raw.githubusercontent.com/jamiew/git-friendly/master/install.sh | bash -s ~/friendly

Manual Install

Checkout the code:

git clone git://github.com/jamiew/git-friendly.git ~/dev/git-friendly

Then update your ~/.bash_profile or ~/.bashrc to make git-friendly available each time you launch a new terminal:

export PATH=~/dev/git-friendly:$PATH

Usage

You now have new awesome commands: branch, merge, pull, push and stash:

Example session:

pull
branch awesomeness # Create a new branch (or switch to existing one)
echo "BUMP" >> README
git commit -a -m "Righteous bump"
branch master      # Switch back to master
merge awesomeness  # Merge awesomeness branch to master
push               # Push changes

Commands

branch

Switch branches or create new local branch if it doesn’t exist. Intelligently sets up remote branch tracking so you can just type git pull and not always git pull origin newbranch. If no argument specified, will list all local and remote branches.

branch [name]

Supports branch deletion with -d or -D keys:

branch -d [name]
branch -D [name]

And switching to a previous branch with -:

branch -

merge

  • Merge the specified branch into the current branch;
  • rebase first if the branch is local-only.
merge [name]

pull

  • Stash any local changes;
  • pull from the remote using rebase;
  • update submodules;
  • pop your stash;
  • run bundle install, npm install, yarn install, bower install or composer install if there are any changes in Gemfile, package.json, etc.

push

Any extra arguments will be passed through to git push, for example push -f.

stash

  • Stashes untracked files by default, when run without arguments;
  • behaves like normal git stash otherwise.
stash
stash pop

Configuration

To disable bundle install, npm install, yarn install, bower install or composer install for the pull command use environmental variables:

  • GIT_FRIENDLY_NO_BUNDLE: disables bundle install
  • GIT_FRIENDLY_NO_NPM: disables npm install
  • GIT_FRIENDLY_NO_YARN: disables yarn install
  • GIT_FRIENDLY_NO_BOWER: disables bower install
  • GIT_FRIENDLY_NO_COMPOSER: disables composer install

For example, add this line to your ~/.bash_profile to disable bundle install:

export GIT_FRIENDLY_NO_BUNDLE=true

Bonus: Pimp Your Configs

We strongly recommend editing your global ~/.gitconfig and adding features like ANSI color, command aliases (like git st instead of git status), automatic remote tracking and more. Check out this sample ~/.gitconfig to get started.

We also recommend adding the current Git branch to your Terminal prompt (PS1) or you’ll quickly lose your place — here is a pimp_prompt() bash function which goes in your ~/.bash_profile or ~/.bashrc, then type source ~/.bashrc to reload.

Bonus: Shell Completion

Bash Shell Completion

Add to your shell config file .bash_profile, .bashrc or .profile:

if type __git_complete &> /dev/null; then
  _branch () {
    delete="${words[1]}"
    if [ "$delete" == "-d" ] || [ "$delete" == "-D" ]; then
      _git_branch
    else
      _git_checkout
    fi
  }

  __git_complete branch _branch
  __git_complete merge _git_merge
fi;

Now typing branch <tab> will suggest or autocomplete branches you can checkout to, branch -d <tab> branches you can delete and merge <tab> branches you can merge.

Note: You need to call your git-completion script before the snippet.

Zsh Shell Completion

Add to your .zshrc:

fpath=($(brew --prefix)/share/zsh/functions $fpath)
autoload -Uz _git && _git
compdef __git_branch_names branch

Now you can type branch, press Tab and you’ll see a list of branches in your repo.

Note: You’ll need to adjust the path in the first line if you’re not using Homebrew or macOS.

License

MIT license.

Fork away, do whatever. Pull requests welcome.

Following the practices of Rubinius, anyone who submits an accepted patch is granted a commit bit (write access to the repository).

Following the practices of FAT Lab, anyone who submits an accepted patch is granted credit and attribution bits.

Contributors


Jamie Wilkinson

💻 📖

Artem Sapegin

💻 📖

Maciej Małecki

💻

John Manoogian III

💻

Rafael Corrêa Gomes

📖

Harold Dennison

💻

Ruan Carlos

💻

Ethan Bruning

💻

Ezekiel Templin

📖

Andriy

💻

Ben Zörb

💻

Pavel Prichodko

📖

CJ Lazell

💻