-1

I am trying to push my local branch 'opt' to remote branch origin/tech. My head points to the remote branch origin/tech. I am using the following command

git push -u origin/tech opt

But its failing with the error

fatal: 'origin/tech' does not appear to be a git repository
fatal: could not read from the remote repository

The remote branch origin/tech has been confirmed to exist by doing git branch -r.

Hodor
  • 9
  • 4
  • Possible duplicate of [git push to remote branch](http://stackoverflow.com/questions/6279082/git-push-to-remote-branch) – Blackus Jun 23 '16 at 13:57
  • git branch -r lists branches. If it outputs ```origin/tech```, it means that ```origin``` is a remote while ```tech``` is a branch on that remote. – BartBog Jun 23 '16 at 14:02

3 Answers3

0

I guess that origin/tech is a remote branch, not a remote

git branch -r lists branches. If it outputs origin/tech, it means that origin is a remote while tech is a branch on that remote.

So you should do

git push -u origin opt:tech

to push your local branch opt to the remote branch tech.

See https://git-scm.com/docs/git-push

In particular take a look at the examples on the bottom of the page.

BartBog
  • 1,889
  • 14
  • 28
0
git push origin opt:tech

origin is your name of your remote. opt:tech has to be understand as local_branch:remote_branch.

Blackus
  • 6,883
  • 5
  • 40
  • 51
0

The below error could be caused if either the branch name doesn't match or the remote url is not configured

fatal: 'origin/tech' does not appear to be a git repository

fatal: could not read from the remote repository

  1. Fix when branch doesn't exist:

     git push -u origin opt:tech
    
  2. When remote url is not configured:

    Check if the remote url is added using git remote -v and if not then use the below to add a remote:

     git remote add origin <remote url>
    
Community
  • 1
  • 1
Aditya Singh
  • 15,810
  • 15
  • 45
  • 67