3

Is there a way to push a branch to a Git remote without checking that branch out first?

Say I am on the master branch, and there is a release branch that I want to push to the remote, is there a way to push the release branch to the Git remote without having to check it out first?

  • 1
    https://stackoverflow.com/questions/18031946/what-does-set-upstream-do – jmargolisvt Jul 14 '18 at 19:43
  • 1
    @jmargolisvt did you read the question? The answer in that link says "sets the default remote branch for the current local branch." The point of this question is push a branch to a remote, if you haven't currently checked that branch out – Alexander Mills Jul 14 '18 at 22:46
  • @AlexanderMills looks like at least two other people agree that setting upstream might be the answer the OP is looking for. If you think you have a better reading of the question, I encourage you to post your answer. – jmargolisvt Jul 15 '18 at 13:23

2 Answers2

1

Try this:

git push -u origin new_branch_name

Thiru
  • 2,541
  • 4
  • 25
  • 39
0

This question looks to me like a duplicate of push an 'unchecked out' branch. (Hooray for the "related" section.)

If the feature branch has the same name in both the local repository and in origin, you can use the following shorthand:

git push origin <feature_branch_name>

See this example in the manual. Otherwise specify both names with

git push origin <local_branch_name>:<remote_branch_name>
Ryan M
  • 1