Skip to content

Commit

Permalink
Merge pull request #767 from spacewander/rename_branch_order
Browse files Browse the repository at this point in the history
git-rename-branch: change branch argument order
  • Loading branch information
spacewander committed Jul 6, 2019
2 parents defa89c + df06f3e commit 500ea2b
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 24 deletions.
2 changes: 1 addition & 1 deletion Commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,7 @@ Rename a branch locally, and sync to remote via `git push`.

```
# renames any branch
$ git rename-branch new-name old-name
$ git rename-branch old-name new-name
# renames current branch
$ git rename-branch new-name
Expand Down
10 changes: 8 additions & 2 deletions bin/git-rename-branch
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,14 @@ set -e
# Assert there is at least one branch provided
test -z $1 && echo "new branch name required." 1>&2 && exit 1

new_branch="$1"
old_branch="${2-$(git symbolic-ref --short -q HEAD)}"
if [ -z $2 ]; then
new_branch="$1"
old_branch="$(git symbolic-ref --short -q HEAD)"
else
new_branch="$2"
old_branch="$1"
fi

remote=$(git config branch."$old_branch".remote; true)

git branch -m "$old_branch" "$new_branch"
Expand Down
14 changes: 7 additions & 7 deletions man/git-rename-branch.1
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
.\" generated with Ronn/v0.7.3
.\" http://github.com/rtomayko/ronn/tree/0.7.3
.
.TH "GIT\-RENAME\-BRANCH" "1" "October 2017" "" "Git Extras"
.TH "GIT\-RENAME\-BRANCH" "1" "July 2019" "" "Git Extras"
.
.SH "NAME"
\fBgit\-rename\-branch\fR \- rename local branch and push to remote
.
.SH "SYNOPSIS"
\fBgit\-rename\-branch\fR <new\-branch> <old\-branch>
\fBgit\-rename\-branch\fR <old\-branch> <new\-branch>
.
.SH "DESCRIPTION"
.
Expand All @@ -21,21 +21,21 @@ Rename local branch and push the new branch to remote
.
.nf

&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\.

&lt;new\-branch&gt;

New branch name
.
.fi
.
.SH "EXAMPLES"
.
.nf

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

$ git rename\-branch new\-name
.
Expand Down
16 changes: 8 additions & 8 deletions man/git-rename-branch.html

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

12 changes: 6 additions & 6 deletions man/git-rename-branch.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,25 @@ git-rename-branch(1) -- rename local branch and push to remote

## SYNOPSIS

`git-rename-branch` &lt;new-branch&gt; &lt;old-branch&gt;
`git-rename-branch` &lt;old-branch&gt; &lt;new-branch&gt;

## 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.

&lt;new-branch&gt;

New branch name

## EXAMPLES

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

$ git rename-branch new-name

Expand Down

0 comments on commit 500ea2b

Please sign in to comment.