From 5a8ce5e3645ecdd22a181e0037ae564507f4d25e Mon Sep 17 00:00:00 2001 From: Hozefa Date: Sat, 10 Sep 2016 20:41:32 -0700 Subject: [PATCH] add rename-branch command (#576) --- Commands.md | 12 ++++ bin/git-rename-branch | 13 ++++ etc/git-extras-completion.zsh | 1 + man/git-rename-branch.1 | 51 ++++++++++++++ man/git-rename-branch.html | 125 ++++++++++++++++++++++++++++++++++ man/git-rename-branch.md | 38 +++++++++++ 6 files changed, 240 insertions(+) create mode 100755 bin/git-rename-branch create mode 100644 man/git-rename-branch.1 create mode 100644 man/git-rename-branch.html create mode 100644 man/git-rename-branch.md diff --git a/Commands.md b/Commands.md index 7390dfa..fb954f2 100644 --- a/Commands.md +++ b/Commands.md @@ -40,6 +40,7 @@ - [`git rebase-patch`](#git-rebase-patch) - [`git reauthor`](#git-reauthor) - [`git release`](#git-release) + - [`git rename-branch`](#git-rename-branch) - [`git rename-tag`](#git-rename-tag) - [`git repl`](#git-repl) - [`git reset-file`](#git-reset-file) @@ -361,6 +362,17 @@ Does the following: - Executes _.git/hooks/post-release.sh_ (if present) +## git rename-branch + +Rename a branch (locally and remotely). +``` +# renames any branch +$ git rename-branch new-name old-name + +# renames current branch +$ git rename-branch new-name +``` + ## git rename-tag Rename a tag (locally and remotely). diff --git a/bin/git-rename-branch b/bin/git-rename-branch new file mode 100755 index 0000000..8201aa8 --- /dev/null +++ b/bin/git-rename-branch @@ -0,0 +1,13 @@ +#!/usr/bin/env bash + +# Assert there is at least one branch provided +test -z $1 && echo "new branch name required." 1>&2 && exit 1 + +if [ -z $2 ] + then + $2=${git symbolic-ref --short -q HEAD} +fi + +git branch -m $2 $1 +git push origin :$2 +git push --set-upstream origin $1 diff --git a/etc/git-extras-completion.zsh b/etc/git-extras-completion.zsh index b6dec9b..daaabf5 100644 --- a/etc/git-extras-completion.zsh +++ b/etc/git-extras-completion.zsh @@ -393,6 +393,7 @@ zstyle ':completion:*:*:git:*' user-commands \ rebase-patch:'rebases a patch' \ refactor:'create refactor branch' \ release:'commit, tag and push changes to the repository' \ + rename-branch:'rename a branch' \ rename-tag:'rename a tag' \ repl:'git read-eval-print-loop' \ reset-file:'reset one file' \ diff --git a/man/git-rename-branch.1 b/man/git-rename-branch.1 new file mode 100644 index 0000000..9a92f03 --- /dev/null +++ b/man/git-rename-branch.1 @@ -0,0 +1,51 @@ +.\" generated with Ronn/v0.7.3 +.\" http://github.com/rtomayko/ronn/tree/0.7.3 +. +.TH "GIT\-RENAME\-BRANCH" "1" "September 2016" "" "" +. +.SH "NAME" +\fBgit\-rename\-branch\fR \- rename local branch and push to remote +. +.SH "SYNOPSIS" +\fBgit\-rename\-branch\fR +. +.SH "DESCRIPTION" +. +.nf + +Rename local branch and push the new branch to remote +. +.fi +. +.SH "OPTIONS" +. +.nf + +<new\-branch> + +New branch name + +<old\-branch> + +Old branch whose has to be renamed\. This is an optional parameter\. If no value is supplied then the current branch will be renamed\. +. +.fi +. +.SH "EXAMPLES" +. +.nf + +$ git rename\-branch new\-name old\-name + +$ git rename\-branch new\-name +. +.fi +. +.SH "AUTHOR" +Written by Hozefa Jodiawalla <\fIhozefarules@gmail\.com\fR> +. +.SH "REPORTING BUGS" +<\fIhttps://github\.com/tj/git\-extras/issues\fR> +. +.SH "SEE ALSO" +<\fIhttps://github\.com/tj/git\-extras\fR> diff --git a/man/git-rename-branch.html b/man/git-rename-branch.html new file mode 100644 index 0000000..73224f1 --- /dev/null +++ b/man/git-rename-branch.html @@ -0,0 +1,125 @@ + + + + + + git-rename-branch(1) - rename local branch and push to remote + + + + +
+ + + +
    +
  1. git-rename-branch(1)
  2. +
  3. +
  4. git-rename-branch(1)
  5. +
+ +

NAME

+

+ git-rename-branch - rename local branch and push to remote +

+ +

SYNOPSIS

+ +

git-rename-branch <new-branch> <old-branch>

+ +

DESCRIPTION

+ +
Rename local branch and push the new branch to remote
+
+ +

OPTIONS

+ +
&lt;new-branch&gt;
+
+New branch name
+
+&lt;old-branch&gt;
+
+Old branch whose has to be renamed. This is an optional parameter. If no value is supplied then the current branch will be renamed.
+
+ +

EXAMPLES

+ +
$ git rename-branch new-name old-name
+
+$ git rename-branch new-name
+
+ +

AUTHOR

+ +

Written by Hozefa Jodiawalla <hozefarules@gmail.com>

+ +

REPORTING BUGS

+ +

<https://github.com/tj/git-extras/issues>

+ +

SEE ALSO

+ +

<https://github.com/tj/git-extras>

+ + +
    +
  1. +
  2. September 2016
  3. +
  4. git-rename-branch(1)
  5. +
+ +
+ + diff --git a/man/git-rename-branch.md b/man/git-rename-branch.md new file mode 100644 index 0000000..17aba68 --- /dev/null +++ b/man/git-rename-branch.md @@ -0,0 +1,38 @@ +git-rename-branch(1) -- rename local branch and push to remote +================================ + +## SYNOPSIS + +`git-rename-branch` <new-branch> <old-branch> + +## DESCRIPTION + + Rename local branch and push the new branch to remote + +## OPTIONS + + <new-branch> + + New branch name + + <old-branch> + + Old branch whose has to be renamed. This is an optional parameter. If no value is supplied then the current branch will be renamed. + +## EXAMPLES + + $ git rename-branch new-name old-name + + $ git rename-branch new-name + +## AUTHOR + +Written by Hozefa Jodiawalla <> + +## REPORTING BUGS + +<> + +## SEE ALSO + +<>