fatal: ambiguous argument 'origin': unknown revision or path not in the working tree

后端 未结 6 2046
伪装坚强ぢ
伪装坚强ぢ 2020-12-14 05:34

I used git diff origin often in the past.

In a different environment it does not work. I have no clue why.

user@host> git diff origin         


        
6条回答
  •  青春惊慌失措
    2020-12-14 06:09

    If origin points to a bare repository on disk, this error can happen if that directory has been moved (even if you update the working copy's remotes). For example

    $ mv /path/to/origin /somewhere/else
    $ git remote set-url origin /somewhere/else
    $ git diff origin/master
    fatal: ambiguous argument 'origin': unknown revision or path not in the working tree.
    

    Pulling once from the new origin solves the problem:

    $ git stash
    $ git pull origin master
    $ git stash pop
    

提交回复
热议问题