我有一个非常奇怪的问题与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
什么好主意吗?
我有一个非常奇怪的问题与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
什么好主意吗?
当前回答
创建一个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
其他回答
如果您包括您的用户名和回购名称,我们可以合理地帮助您,目前我们没有理由认为回购确实存在。
此外,如果回购是私有的,并且您无法访问它,github将返回“不存在”,以避免披露私有回购的存在。
编辑:如果你不能克隆它,因为它说它不存在,它是私有的,这是因为你没有发送身份验证。确保您的公钥已添加到密匙环,或暂时使用HTTP基本身份验证。
我在使用Android Studio时遇到了同样的问题,由于身份验证错误,我无法推送提交。
我的临时解决方案是使用GitHub桌面应用程序来推送我的提交,它工作得很好。
下面为我解决了这个问题。
首先,我使用这个命令来确定使用的github帐户是什么:
ssh -T git@github.com
这给了我一个这样的答案:
Hi <github_account_name>! You've successfully authenticated, but GitHub does not provide shell access. I just had to give the access to fix the problem.
然后我明白了答案中描述的Github用户(github_account_name)在我试图拉的Github存储库上没有授权。
我通过Github重新认证解决了这个问题。
如果你有Github CLI,你可以输入gh auth登录
如果你的repo之前工作正常,突然弹出这个错误,最有可能的原因是你的git被认证为其他用户,没有访问存储库的权限。因此,为了进行推送,您所需要做的就是在git命令中指定正确的用户名和密码。所以,一个github回购的推命令看起来像:
git push https://youruser:password@github.com/user/reponame.git
用户名和密码需要进行url转义,因此@应该被%40取代,等等。