fatal-'origin'似乎不是git存储库

时间:2018-07-11 06:55:36

标签: git github

我创建了一个远程仓库,然后在本地创建了一个本地仓库:

git init

然后使用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.

我应该在某些命令中使用远程还是本地命令?如果可以,我是否已经添加并提交了,还是应该从本地重新开始?

编辑:

显然我应该添加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.

7 个答案:

答案 0 :(得分:6)

尝试

git remote add origin <https://github.com/"username"/"repository".git> 

然后尝试再次

git push -u origin master

答案 1 :(得分:5)

运行 AlertDialog.Builder builder = new AlertDialog.Builder(context); builder.setTitle("WiFi Settings"); builder.setMessage("Please enable internet connection"); builder.setCancelable(false); builder.setPositiveButton("Ok", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { // Launch settings activity startActivity(new Intent(Settings.ACTION_WIFI_SETTINGS));); } }); builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.cancel(); } }); builder.create().show(); 克隆存储库时,将自动创建默认的远程git clone <repo_url>。如果存储库是由origin创建的,则没有默认的远程,也没有git init。您需要自行设置。

origin

git remote add origin <repo_url> 是您要与交换数据的现有远程存储库的路径。如果位于本地磁盘中,则可以为repo _urlfile:///home/me/foo.git。如果托管在Github中,则可以为/home/me/foo.githttps://github.com/me/foo.git

关于“先获取”的第二个错误。您需要在下一次推送之前运行ssh://git@github.com/me/foo.gitgit pull origin <branch>

答案 2 :(得分:2)

尝试执行PR时,我也遇到了同样的错误消息。仔细看,我意识到我正在错误的目录上执行Git工作流程。

对于我来说,我只是简单地使用** cd .. **返回到正确的目录,然后继续进行,而没有更多错误。

答案 3 :(得分:0)

git remote add origin <url>

然后

git push -u origin master

答案 4 :(得分:0)

在命令下运行

git remote add origin git@github.com:xxxx/xxxx.git

请不要使用SSH!

答案 5 :(得分:0)

首先,您需要运行以下命令:

git remote add origin https://github.com/"USERNAME"/"REPOSITORY_NAME".git

此后:

git push -u origin "branch name"

这可以工作!!!

答案 6 :(得分:-2)

发生这种情况是因为您的配置文件包含主词而不是heroku git url。当您多次初始化git时,可能会发生这种情况。

  1. 编辑配置文件

    git config --e

  2. 然后将主单词编辑为heroku网址,例如https://git.heroku.com/project_name.git

  3. 保存它!

  4. 然后通过git push heroku master推送更新

希望这对您有所帮助!