为什么Git告诉我“没有这样的远程'起源'”,当我试图推动起源? [英] Why does Git tell me "No such remote 'origin'" when I try to push to origin?

查看:155
本文介绍了为什么Git告诉我“没有这样的远程'起源'”,当我试图推动起源?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对Git非常陌生,我只是最近创建了一个GitHub账户。



我试图推送我的第一个仓库(一个示例项目),但出现以下错误:

 没有这样的远程'origin'

我运行了以下命令:

  git init 
git commit -mfirst提交
git remote add origin https://github.com/VijayNew/NewExample.git
git push -u origin master

但是,当我运行git commit -mfirst commit时,我收到以下消息:

 





















然后我试着设置 origin ,使用

  git remote set-url origin https://github.com/VijayNew/NewExample.git 

但是我得到了以下错误:

 没有这样的远程'origin'

我做错了什么,我应该怎么做?

解决方案

两个问题:



1 - 你从未告诉Git开始跟踪任何文件



你写的是你跑的

  git init 
git commit -m第一次提交

,并且在那个阶段,你得到了

 没有添加任何东西来提交,但未跟踪的文件目前(使用git add来追踪)。 

Git告诉你,你从来没有让它开始跟踪任何文件,没有什么可以拍摄的。因此,Git不会创建任何提交。在尝试提交之前,您应该告诉Git(例如):


嗨Git,您会看到 README。 md 文件闲置在我的工作目录中,那里?你可以把它放在我的版本控制下吗?我希望它进入我的第一次提交/快照/修订...

为此,您需要 阶段 感兴趣的文件,使用

  git add README.md 
$ b $ before 运行

  git commit  - m一些描述性消息 - 您尚未设置远程存储库 2您尚未设置远程存储库      

然后你运行

  git remote add origin https://github.com/ VijayNew / NewExample.git 

之后,您的本地存储库应该能够与远程存储库驻留在指定的URL( https://github.com/VijayNew/NewExample.git )。 ..提供远程回购确实存在!
然而,你似乎从来没有在GitHub上创建过这个远程回购:在写这个答案的时候,如果我试图访问相应的URL,我会得到





在尝试推送到远程存储库之前,您需要确保后者实际存在。所以去GitHub并创建有问题的远程回购。然后,只有这样,才能成功推送

  git push -u原产主


I am very new to Git; I only recently created a GitHub account.

I've just tried to push my very first repository (a sample project), but I'm getting the following error:

No such remote 'origin'

I ran the following commands:

git init
git commit -m "first commit"
git remote add origin https://github.com/VijayNew/NewExample.git
git push -u origin master

However, when I ran git commit -m "first commit", I got the following message:

nothing added to commit but untracked files present (use "git add" to track)

So then I tred to set origin, using

git remote set-url origin https://github.com/VijayNew/NewExample.git

But I got the following error:

No such remote 'origin'

What did I do wrong, and what should I do?

解决方案

Two problems:

1 - You never told Git to start tracking any file

You write that you ran

git init
git commit -m "first commit"

and that, at that stage, you got

nothing added to commit but untracked files present (use "git add" to track).

Git is telling you that you never told it to start tracking any files in the first place, and it has nothing to take a snapshot of. Therefore, Git creates no commit. Before attempting to commit, you should tell Git (for instance):

Hey Git, you see that README.md file idly sitting in my working directory, there? Could you put it under version control for me? I'd like it to go in my first commit/snapshot/revision...

For that you need to stage the files of interest, using

git add README.md

before running

git commit -m "some descriptive message"

2 - You haven't set up the remote repository

You then ran

git remote add origin https://github.com/VijayNew/NewExample.git

After that, your local repository should be able to communicate with the remote repository that resides at the specified URL (https://github.com/VijayNew/NewExample.git)... provided that remote repo actually exists! However, it seems that you never created that remote repo on GitHub in the first place: at the time of writing this answer, if I try to visit the correponding URL, I get

Before attempting to push to that remote repository, you need to make sure that the latter actually exists. So go to GitHub and create the remote repo in question. Then and only then will you be able to successfully push with

git push -u origin master

这篇关于为什么Git告诉我“没有这样的远程'起源'”,当我试图推动起源?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆