我创建了一个远程仓库,然后在本地创建了一个本地仓库:
git init
Run Code Online (Sandbox Code Playgroud)
然后添加的文件,我需要用git add那么git commit -m "something"
最后 git push origin master
我得到了致命的错误消息:
'origin' does not appear to be a git repository
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
Run Code Online (Sandbox Code Playgroud)
我应该在某些命令或某些内容中喜欢远程和本地吗?如果可以,是否已经添加并提交,还是应该从本地重新开始?
编辑:
显然我应该添加,git remote add origin ssh://git@example.com:1234/myRepo.git
但是我应该用什么替换该ssh,如在哪里可以找到我应该添加的版本。
得到这个错误:
! [rejected] master -> master (fetch first)
error: failed to push some refs to
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
Run Code Online (Sandbox Code Playgroud)
Elp*_*Kay 11
运行git clone <repo_url>克隆存储库时,将origin自动创建默认远程。如果存储库是由创建的git init,则没有默认的远程,没有origin。您需要自行设置。
git remote add origin <repo_url>
Run Code Online (Sandbox Code Playgroud)
repo _url是要与之交换数据的现有远程存储库的路径。如果在本地磁盘中,则可能是file:///home/me/foo.git或/home/me/foo.git。如果托管在Github中,则可能是https://github.com/me/foo.git或ssh://git@github.com/me/foo.git。
至于关于“先获取”的第二个错误。您需要运行git pull origin <branch>或git pull -r origin <branch>在下一次推送之前。
小智 7
尝试这个
git remote add origin <https://github.com/"username"/"repository".git>
Run Code Online (Sandbox Code Playgroud)
然后再试一次
git push -u origin master
Run Code Online (Sandbox Code Playgroud)
小智 5
git remote add origin <url>
Run Code Online (Sandbox Code Playgroud)
然后
git push -u origin master
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
22582 次 |
| 最近记录: |