簡體   English   中英

通過'git remote add origin'和'push'創建新的倉庫

[英]Create new repo by 'git remote add origin' and 'push'

當創建本地存儲庫並嘗試將其推送到github ,最終出現問題:

 ERROR: Repository not found. fatal: The remote end hung up unexpectedly 

我的步驟是標准的-gitHub幫助建議的步驟。

touch README.md
git init
git add README.md
git commit -m "first commit"
git remote add origin git@github.com:MyUser/my-samples.git
git push -u origin master

然后: git push -u origin master

問: 如何將新的倉庫/分支推送到github

只是澄清一下:我想從命令行遠程創建新存儲庫-它在我的github上尚不存在。

基本上我想在http://try.github.io/上執行第11步

順便說一句。 當我嘗試使用https://而不是git@github.com:... (遵循以下步驟)時,我最終遇到403錯誤

如果我使用"ssh://" ,在github上添加密鑰 ,最終將導致Repository not found error 但是sh -T git@github.com測試成功通過,

所以更新是的我檢查了我的連接

因此,我想一個簡單的答案是: 不可能通過git remote addpush命令遠程 創建repo

因此,當我這樣做時: git remote add origin git@github.com:MyUser/my-samples.git

並不意味着它要在遠程主機上創建新的回購協議。 這意味着它將把我的origin master分支鏈接到應該存在的遠程分支

然后,可能存在一個可以遠程創建存儲庫/項目的命令。

但這是不同的- 不是git remote add .. 然后推送。

話雖如此,我認為+ Akash Agrawal的權利。 回答我的問題只是為了讓自己清楚。

-

這回答了我的問題,如何從命令行遠程創建它: 是否可以在不打開瀏覽器的情況下從CLI在GitHub上創建遠程倉庫?

curl -u 'USER' https://api.github.com/user/repos -d '{"name":"REPO"}'

或HUB: http//hub.github.com/

# create a repo for a new project
$ git init
$ git add . && git commit -m "It begins."
$ git create -d "My new thing"
→ (creates a new project on GitHub with the name of current directory)
$ git push origin master

您將需要在github上創建一個倉庫,以便將您的更改推送到倉庫。 裸存儲庫不會自動初始化。 否則,拼寫錯誤會導致不良的新存儲庫創建。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM