我试图设置git与http://danielmiessler.com/study/git/#website来管理我的网站。

我已经到了指令的最后一步:git push website +master:refs/heads/master

我正在win7中使用git ming32命令行工作

$ git push website +master:refs/heads/master
Bill@***.com's password:
Connection closed by 198.91.80.3
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

这里的一个问题可能是程序正在寻找bill@* **.com。当我通过ssh连接到我的网站,我有一个不同的用户名(让我们说'abc')。也许这个应该是abc@***。com。如果是这样,我不知道如何改变这一点,或者如果我可以推下一个别名


当前回答

在你的。git/config文件中

[remote "YOUR_APP_NAME"]
    url = git@heroku.com:YOUR_APP_NAME.git
    fetch = +refs/heads/*:refs/remotes/YOUR_APP_NAME/*

并简单地

git push YOUR_APP_NAME master:master 

其他回答

git branch——set-upstream-to=origin/(分支名)

我也犯了同样的错误,这让我得到了这个没有帮助的答案。 我试图创建一个新的“裸”存储库,第一次使用以下命令跟踪到NTFS位置:

cd myrepository
git init --bare \\myserver.mycompany.local\myrepository.git
git init
git status
git add .
git status
git commit -m "Initial Commit"
git remote add origin \\myserver.mycompany.local\myrepository.git
git push -u origin master
git status

我的问题原来是在NTFS位置中使用后斜杠而不是前斜杠,当试图添加原点来设置(新的)跟踪上游分支时。

我必须删除原点使用:

git remote rm origin

然后使用预期的正斜杠再次添加原点

git remote add origin //myserver.mycompany.local/myrepository.git

希望这对将来的人有所帮助。

在终端上执行以下命令确保ssh-agent正在运行:

eval $(ssh-agent -s)

来源:Github文档

I would recommend to check all remotes you have configured with git remote -v If you had your repo configured to a remote that was deleted you will receive this error message: fatal: Could not read from remote repository. Please make sure you have the correct access rightsand the repository exists. Even when trying to push or pull to an other (existing) remote. So if you have a remote that was deleted, you can remove with git remote remove name-of-remote-to-remove and after that you can push or pull to your existing remotes without problems.

user@server:/etc/nginx$ cat .git/config 
...
[remote "origin"]
    url = git@gitlab.com:user/.git
    fetch = +refs/heads/*:refs/remotes/origin/*
...

使用ssh代替https。 在git中使用ssh密钥(添加ssh密钥)。 如果您是root用户,请使用ssh密钥。


$ sudo ssh-keygen
$ cat /root/.ssh/id_rsa.pub 

$ git init
$ git add file
$ git commit -m "add first file"
$ git remote add origin git@gitlab.com:user/example.git 
$ git push -u origin master