Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

git-rename-remote: rename a remote regardless of any existing remotes #751

Merged
merged 1 commit into from
May 8, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions Commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
- [`git release`](#git-release)
- [`git rename-branch`](#git-rename-branch)
- [`git rename-tag`](#git-rename-tag)
- [`git rename-remote`](#git-rename-remote)
- [`git repl`](#git-repl)
- [`git reset-file`](#git-reset-file)
- [`git root`](#git-root)
Expand Down Expand Up @@ -509,6 +510,19 @@ $ git tag
test2
```

## git rename-remote

Rename a git remote regardless of name conflict, and then list current git remotes.
```
$ git remote -v
origin [email protected]:myuser/foo.git (fetch)
origin [email protected]:myuser/foo.git (push)
upstream [email protected]:myuser/bar.git (fetch)
upstream [email protected]:myuser/bar.git (push)
$ git-rename-remote upstream origin
origin [email protected]:myuser/bar.git (fetch)
origin [email protected]:myuser/bar.git (push)
```

## git reauthor

Expand Down
20 changes: 20 additions & 0 deletions bin/git-rename-remote
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/usr/bin/env bash

set -euo pipefail

old=$1
new=$2

test -z $old && echo "old remote name required." 1>&2 && exit 1
test -z $new && echo "new remote name required." 1>&2 && exit 1

if ! git config --get "remote.$old.fetch" > /dev/null; then
echo "remote $old doesn't exist"
exit 1
fi

if git config --get "remote.$new.fetch" > /dev/null; then
git remote remove $new
fi
git remote rename $old $new
git remote -v
1 change: 1 addition & 0 deletions etc/git-extras-completion.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -479,6 +479,7 @@ zstyle ':completion:*:*:git:*' user-commands $existing_user_commands \
release:'commit, tag and push changes to the repository' \
rename-branch:'rename a branch' \
rename-tag:'rename a tag' \
rename-remote:'rename a remote' \
repl:'git read-eval-print-loop' \
reset-file:'reset one file' \
root:'show path of root' \
Expand Down
49 changes: 49 additions & 0 deletions man/git-rename-remote.1
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
.\" generated with Ronn/v0.7.3
.\" http://github.com/rtomayko/ronn/tree/0.7.3
.
.TH "GIT\-RENAME\-REMOTE" "1" "May 2019" "" "Git Extras"
.
.SH "NAME"
\fBgit\-rename\-remote\fR \- Rename a remote
.
.SH "SYNOPSIS"
\fBgit\-rename\-remote\fR <old\-remote\-name> <new\-remote\-name>
.
.SH "DESCRIPTION"
Rename a git remote regardless of name conflict, and then list current git remotes
.
.SH "OPTIONS"
<old\-remote\-name>
.
.P
The name of the remote you want to rename\.
.
.P
<new\-remote\-name>
.
.P
The new name of the remote\.
.
.SH "EXAMPLES"
.
.nf

$ git remote \-v
origin git@myserver\.com:myuser/foo\.git (fetch)
origin git@myserver\.com:myuser/foo\.git (push)
upstream git@myserver\.com:myuser/bar\.git (fetch)
upstream git@myserver\.com:myuser/bar\.git (push)
$ git\-rename\-remote upstream origin
origin git@myserver\.com:myuser/bar\.git (fetch)
origin git@myserver\.com:myuser/bar\.git (push)
.
.fi
.
.SH "AUTHOR"
Written by timfeirg <\fIkkcocogogo@gmail\.com\fR>
.
.SH "REPORTING BUGS"
<\fIhttps://github\.com/tj/git\-extras/issues\fR>
.
.SH "SEE ALSO"
<\fIhttps://github\.com/tj/git\-extras\fR>
128 changes: 128 additions & 0 deletions man/git-rename-remote.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

43 changes: 43 additions & 0 deletions man/git-rename-remote.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
git-rename-remote(1) -- Rename a remote
=================================

## SYNOPSIS

`git-rename-remote` &lt;old-remote-name&gt; &lt;new-remote-name&gt;

## DESCRIPTION

Rename a git remote regardless of name conflict, and then list current git remotes

## OPTIONS

&lt;old-remote-name&gt;

The name of the remote you want to rename.

&lt;new-remote-name&gt;

The new name of the remote.

## EXAMPLES

$ git remote -v
origin [email protected]:myuser/foo.git (fetch)
origin [email protected]:myuser/foo.git (push)
upstream [email protected]:myuser/bar.git (fetch)
upstream [email protected]:myuser/bar.git (push)
$ git-rename-remote upstream origin
origin [email protected]:myuser/bar.git (fetch)
origin [email protected]:myuser/bar.git (push)

## AUTHOR

Written by timfeirg &lt;<[email protected]>&gt;

## REPORTING BUGS

&lt;<https://github.com/tj/git-extras/issues>&gt;

## SEE ALSO

&lt;<https://github.com/tj/git-extras>&gt;