1. 程式人生 > >記錄github錯誤

記錄github錯誤

困擾已久的問題,用git push origin master 命令push專案到github上時,總是出現:

fatal : ‘origin’ does not appear to be a git repository

這樣的錯誤,問題在於.git目錄下的config檔案中只有[core],沒有[remote "origin"]和[branch "master"]資訊:

[core] repositoryformatversion = 0 filemode = true bare = false logallrefupdates = true

 也就是說當git push origin master的時候,git需要去config中查詢提交的分支資訊,但是config中又是空的,所以返回這個錯誤。

 

解決的方法就是在config檔案中新增上[remote "origin"]和[branch "master"]這兩個資訊:

[core]
  repositoryformatversion = 0
  filemode = true
  bare = false
  logallrefupdates = true

[remote "origin"]
  url = https://github.com/github名/倉庫名
  fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
  remote = origin
  merge = refs/heads/master

就好啦!    ^_^