1

Based on : How do I push a new local branch to a remote Git repository and track it too?

I have a local branch named as 'new_branch' and I would like to push the local branch to remote as the following:

$ git ls-remote origin
433ecee11614bcda452ddf5817ebb56212d96192        HEAD
94d6b198dd6bbba9520e8aa11a1d6fc67aed818a        refs/heads/feature/f1
76d6b198dd6bbba9520e8aa11a1dafc67aed818a        refs/heads/feature/f2

$git push -u origin feature/new_branch

The git reports the following errors:

fatal: 'origin/feature/new_branch' does not appear to be a git repository fatal: Could not read from remote repository.

I try the following and it works for me but this is not what I want.

$git push -u origin new_branch

My local environment has not installed 'git flow'. Is it possible that I can directly push a non-feature local branch to a feature branch in remote?

Thank you

Community
  • 1
  • 1
q0987
  • 34,938
  • 69
  • 242
  • 387

1 Answers1

1

If you really want to push it to feature/new_branch, do git push origin new_branch:feature/new_branch -u.

However, I would recommend that you just rename your local branch with git branch -m new_branch feature/new_branch first, then push it to origin, to avoid confusion later.

David Deutsch
  • 17,443
  • 4
  • 47
  • 54