-1

Currently I'm using Git flow.

On the branch develop I run this command:

$ git flow hotfix start ID20208

All ok, so far.

Then, I do my changes and I run git add and git commit.

Next, I run git push and I receive this alert:

fatal: The current branch hotfix/ID20208 has no upstream branch. To push the current branch and set the remote as upstream, use

    git push --set-upstream origin hotfix/ID20208

My question is: are these the correct steps to push a hotfix to the server?

Scott Weldon
  • 9,673
  • 6
  • 48
  • 67
jjoselon
  • 2,641
  • 4
  • 23
  • 37
  • 5
    The branch has nowhere's to be pushed to. The `git push --set-upstream origin hotfix/ID20208` tells it where it gets pushed to. You either have to run that, so it has somewhere to go on the git server, or you have to merge it into another branch that has somewhere to go. I've never used "git flow", so there could be another command it has to push the hotfix to master or some other branch, but with vanilla git that's what you would do. – Adam LeBlanc Jun 14 '17 at 16:20

1 Answers1

1

As indicated by the error message, Git doesn't know what to push and where to push it to.

To just fix this issue, you can run the command given:

git push --set-upstream origin hotfix/ID20208

(You can also use -u instead of --set-upstream.)

Alternatively, you could use the git-flow command that does the same thing:

git flow hotfix publish ID20208

The reason you got this error is, by default, Git refuses to push your branch if you haven't set an upstream branch. To simplify your workflow, you could tell Git to always push the current branch to update a branch with the same name on the remote server. To do that, you can set this config value:

git config push.default current

Then you should be able to do a plain git push on any new branch and it will do what you want.

Scott Weldon
  • 9,673
  • 6
  • 48
  • 67
  • In Sourcetree, I renamed a feature branch to a hotfix branch. Because of this Sourcetree got confused and couldn't recognice the hotfix branch when I tried to push to server. So I had to open the terminal and then run your first command (```git push --set-upstream origin hotfix/ID20208```) – Joel Wiklund Mar 05 '20 at 12:44