Discover, install, and configure shell plugins with Fig Plugin Store →

Git Add Remote

ZSH plugin to easily add the upstream remote to your git fork.

13 stars
5 forks

git-add-remote Build Status

A shell plugin to easily add remotes to git repositories.


It is so damn boring to type or copy and paste the URLs changing only the fork name.


Given that you are in a valid git managed folder, with a remote named origin, you can, for example, add your company's remote as upstream:

$ add-upstream company

$ git remote -v
origin (fetch)
origin (push)
upstream (fetch)
upstream (push)

Or even add your coworker's remote to work in some branch together:

$ add-remote my-coworker

$ git remote -v
origin (fetch)
origin (push)
my-coworker (fetch)
my-coworker (push)

Some people have hard aliases in github, so you can even set the remote's name:

$ add-remote _c0w0rk3r_0x12 newguy

$ git remote -v
origin (fetch)
origin (push)
newguy (fetch)
newguy (push)

newguy's tend to multiply, so I don't recommend naming it like that.


It was innitialy made to be used in ZSH, so, if you use antibody, antigen, or whatever, just bundle it:

$ antibody bundle caarlos0/git-add-remote

If you use bash, you can clone this repo somewhere or just download the file and source the file in your ~/.profile or wherever you like.

git aliasing

$ git config --global alias.add-upstream '!zsh -ic \"add-upstream $*\"''
$ git config --global alias.add-remote '!zsh -ic \"add-remote $*\"''
$ git add-upstream org
$ git add-remote user remote_name
$ git add-remote user

These examples are for zsh, but I'm pretty sure they also work on bash by replacing zsh -ic with bash -ic.