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:
- does the most useful thing by default; plus
- push copies a GitHub compare URL to your clipboard;
- pull runs commands like
bundle install
,npm install
,yarn install
,pnpm install
andcomposer install
if necessary; - branch tracks remote branches if they are available;
- stash includes untracked files by default.
Less time fighting Git — more time actually doing work.
brew install git-friendly/git-friendly/git-friendly
The Homebrew tap for this project can be found here
Unofficial builds of stable releases can be found in Fedora Copr: fuhrmann/git-friendly.
dnf copr enable fuhrmann/git-friendly
dnf install git-friendly
Run this one-liner, which will download the scripts into /usr/local/bin
:
curl -sS https://raw.githubusercontent.com/git-friendly/git-friendly/main/install.sh | bash
Note
If you don’t have write access to /usr/local/bin
you’ll need to run this command using sudo
.
You can change the installation directory:
curl -sS https://raw.githubusercontent.com/git-friendly/git-friendly/main/install.sh | bash -s ~/bin/git-friendly
Checkout the code:
git clone git://github.com/git-friendly/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
You now have some awesome new 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 main # Switch back to main
merge awesomeness # Merge awesomeness branch to main
push # Push changes
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 the specified branch into the current branch;
- rebase first if the branch is local-only.
merge [name]
- Stash any local changes;
- pull from the remote using rebase;
- update submodules;
- pop your stash;
- run
bundle install
,npm install
,yarn install
,pnpm install
orcomposer install
if there are any changes inGemfile
,package.json
, etc.
- Push your changes to the remote;
- copy a compare URL, like https://github.com/git-friendly/git-friendly/compare/e96033...5daed4, to your clipboard (works on Mac and Linux).
Any extra arguments will be passed through to git push
, for example push -f
.
- Stashes untracked files by default, when run without arguments;
- behaves like normal
git stash
otherwise.
stash
stash pop
Change git-friendly behavior using environment variables. For example, add this line to your ~/.bash_profile
to disable running bundle install
in the pull
command:
export GIT_FRIENDLY_NO_BUNDLE=true
Available environment variables:
Variable | Description | Commands | Default value |
---|---|---|---|
GIT_FRIENDLY_NO_BUNDLE |
Disables bundle install |
pull |
false |
GIT_FRIENDLY_NO_COMPOSER |
Disables composer install |
pull |
false |
GIT_FRIENDLY_NO_NPM |
Disables npm install |
pull |
false |
GIT_FRIENDLY_NO_YARN |
Disables yarn install |
pull |
false |
GIT_FRIENDLY_NO_PNPM |
Disables pnpm install |
pull |
false |
GIT_FRIENDLY_NO_REBASE_ON_PULL |
Disables rebasing local commits on top of the updated remote branch | pull |
false |
GIT_FRIENDLY_NO_COPY_URL_AFTER_PUSH |
Disables copying URL to clipboard | push |
false |
- bundler (ruby)
- composer (PHP)
- npm (JavaScript)
- yarn (JavaScript)
- pnpm (JavaScript)
Support for more is always welcome.
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.
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 this snippet.
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.
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.