Skip to content

caarlos0-graveyard/git-add-remote

Repository files navigation

git-add-remote Build Status

A shell plugin to easily add remotes to git repositories.

Why

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

Usage

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  [email protected]:caarlos0/random.git (fetch)
origin  [email protected]:caarlos0/random.git (push)
upstream  [email protected]:company/random.git (fetch)
upstream  [email protected]:company/random.git (push)

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

$ add-remote my-coworker

$ git remote -v
origin  https://github.com/caarlos0/random.git (fetch)
origin  https://github.com/caarlos0/random.git (push)
my-coworker  https://github.com/my-coworker/random.git (fetch)
my-coworker  https://github.com/my-coworker/random.git (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  [email protected]:caarlos0/random.git (fetch)
origin  [email protected]:caarlos0/random.git (push)
newguy  [email protected]:_c0w0rk3r_0x12/random.git (fetch)
newguy  [email protected]:_c0w0rk3r_0x12/random.git (push)

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

Installation

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 add-remote.sh file and source the add-remote.sh file in your ~/.profile or wherever you like.

Fig

Fig adds apps, shortcuts, and autocomplete to your existing terminal.

Install git-add-remote in just one click.

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.

About

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

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •  

Languages