Why does git not recognize “origin/master” as a valid object name?

后端 未结 3 791
无人及你
无人及你 2021-02-19 07:27
~/www> git branch --track live origin/master
fatal: Not a valid object name: \'origin/master\'.
~/www> git remote
origin
~/www> git branch
* master
  test_branc         


        
相关标签:
3条回答
  • 2021-02-19 07:36

    Your output from git remote confirms that you've successfully added your origin remote.

    I expect the problem is that you haven't yet created the remote-tracking branch(es). If you do git branch -r, it probably won't output anything. So origin/master is not a valid object name because that remote-tracking branch doesn't exist yet.

    The solution is to do git fetch origin to create the remote-tracking branch(es). If you then do git branch -r, you'll see origin/master now exists.

    0 讨论(0)
  • 2021-02-19 07:39
    $ git branch -r
      origin/1.x
      origin/1.x@60
      origin/1.x@63
      origin/HEAD -> origin/master
      origin/master
    
    $ git branch --track live origin/blah
    fatal: Not a valid object name: 'origin/blah'.
    

    As has been suggested you can only track a remote if it has been added. Perhaps add the remote like this

    $ git remote add upstream git://github.com/svnpenn/rtmpdump.git
    
    $ git fetch upstream
    

    Example

    0 讨论(0)
  • 2021-02-19 07:46

    I was encountering the very same problem. And it turned out that I didn't have write permission in the remote. And hence the error.

    Make sure you have the write permissions at remote. Not have one is one of the causes of this particular error.

    0 讨论(0)
提交回复
热议问题