2016-10-03 86 views
-3

我對git版本控制很新。 我有一個目錄中的項目。我已經完成了這些步驟:在本地機器上用git上傳

  • 導航到項目目錄。
  • git init
  • git add .
  • git commit -m "First commit"

並試圖上傳使用

git add remote origin https://github.com/userName/repo.git 

到guthub但它給

fatal: pathspec 'remote' did not match any files

+1

[This](https://git-scm.com/book/en/v2)可能會有所幫助! – Praveen

+0

它是'git remote add'而不是'git add remote'。是的,按照Praveen的建議閱讀Git書。 – poke

回答

1

你SY ntax添加遠程是錯誤的。正確的語法是git remote add origin {remote_upstream_name}根據該語法,您必須使用

git remote add origin https://github.com/userName/repo.git

執行此命令後,您將具有遠程原點。

# Verify new remote 
origin https://github.com/user/repo.git (fetch) 
origin https://github.com/user/repo.git (push) 

然後你就可以把你的更改使用以下命令遠程產地:你可以通過執行git remote -v應與URL一起展示你的出身名驗證這一點。

git push -u origin master

這裏-u會保持你當前的分支同步你的遠程分支所以從下一次你可以做git push,它會推動你更改遠程分支。這也取決於其他配置,所以你必須知道git pushgit-push

希望這可以消除你的困惑。讓我們知道這是否有助於您。

+0

我可以驗證新的遠程,但我將如何按項目上傳到該.git。 – Steve

+0

我得到了這兩個錯誤'錯誤:src refspec master不匹配任何。 錯誤:未能推動一些裁判' – Steve

+0

當你執行'git remote -v'時你會得到什麼? – Samundra

相關問題