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-branch: change branch argument order #767

Merged
merged 1 commit into from
Jul 6, 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
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