我有一个非常奇怪的问题与git和github。当我试着推的时候,我得到:

git push -u origin master
ERROR: Repository not found.
fatal: The remote end hung up unexpectedly

我添加了遥控器:

git remote add origin git@github.com:account-name/repo-name.git

什么好主意吗?


当前回答

我得到了同样的错误

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

我在Github上创建了存储库,并在本地克隆了它。

我可以通过打开.git/config并删除[remote "origin"]部分来解决。

[remote "origin"]   
   url = git@github.com:alexagui/my_project.git  
   fetch = +refs/heads/*:refs/remotes/origin/*

然后我运行以下程序(再次)

git remote add origin git@github.com:alexagui/my_project.git  
git push -u origin master

这一次我可以推到存储库。

其他回答

我需要杀死凭证帮助进程(有多个),它在再次提供凭证后解决了这个问题。

killall git-credential-cache——守护进程

检查是否具有读写权限。

Git错误消息具有误导性。我也遇到过类似的问题。我被添加到一个现有的项目中。我克隆了它并提交了一个本地更改。我去推,得到了ERROR: Repository not found。错误消息。

将我添加到项目的人给了我对存储库的只读访问权。他们做出了改变,我得以推动。

git remote rm origin
git remote add origin <remote url>

我得到了同样的错误,因为我改变了我的github用户名,然后我这样做:

git remote -v

然后:

git remote set-url newname newurl 
git push -u origin master

这次我能够推送到存储库。 我希望这能有所帮助。

创建一个Fork

如果没有对该存储库的写访问权,则不需要它。按照下面的说明创建一个fork——它是你自己的存储库的克隆,你可以自由修改。

在创建fork之后,您可以将该repo复制到您的计算机。

git clone git@github.com:<your-git-handle>/<repository>.git
// It will be cloned to your machine where you run the command 
// under a <repository> folder that it will create.

签出一个新的分支并进行更改。

git checkout -b my-new-feature

要将更改提交到原始存储库,您需要确保它们已被推送

/* make changes */
git commit -am "New Feature: Made a new feature!"
git push origin my-new-feature

要将这些更改放到派生出来的原始存储库中,您可以按照以下说明提交一个Pull Requests。Pull Request基本上,你请求对存储库有写访问权限的用户下拉你所做的更改。把它想象成“我请求您将我的更改拉到您的回购中。”


注意:尽管如此,您的分支不会与原始存储库中正在进行的所有更改保持最新。您必须定期删除这些更改—但这很容易。

创建分叉后,你可以链接到你已经分叉的回购,这样你就可以拉进它的变化并保持最新。

git remote add upstream git@github.com:<git-user-handle>/<repository>.git

一旦你做到了这一点,保持与原始回购上所做的更改同步是非常容易的。

git checkout master         // checkout your local master
git pull upstream master    // fetch changes from the master branch of the repo you forked from.. which is linked to your fork under the alias "upstream" (common naming convention)
git push origin master      // push the pulled changes onto your local master
git checkout -b new-branch  // create a new branch and start making changes