Webstorm Git 新远程存储库:推送到 origin/master 被拒绝

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/31009400/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 03:19:44  来源:igfitidea点击:

Webstorm Git new remote repository: Push to origin/master was rejected

gitwebstorm

提问by simple

Simple question: In webstorm, how do I push my local directory to a remote server to make a new remote repository?

简单问题:在 webstorm 中,如何将本地目录推送到远程服务器以创建新的远程存储库?

I created a local repository using webstorm as defined here: https://www.jetbrains.com/pycharm/help/setting-up-a-local-git-repository.html#createNewRepository

我使用此处定义的 webstorm 创建了一个本地存储库:https://www.jetbrains.com/pycharm/help/setting-up-a-local-git-repository.html#createNewRepository

Now I have a local directory with a .git in that directory.

现在我在该目录中有一个带有 .git 的本地目录。

I copied that .git file and put it on my remote server and renamed it as myRemote.git

我复制了那个 .git 文件并将其放在我的远程服务器上并将其重命名为 myRemote.git

In webstorm I: git remote add origin z:\myRemote.git

在 webstorm I: git remote add origin z:\myRemote.git

Then in webstorm I add files and push using the webstorm dialogs.

然后在 webstorm 中我添加文件并使用 webstorm 对话框推送。

I receive an error: Push rejected Push to origin/master was rejected.

我收到一个错误:推送被拒绝 推送到原点/主服务器被拒绝。

What does that mean? Any ideas how I can do this simple push to a remote easily?

这意味着什么?任何想法如何轻松地将这个简单的推送到遥控器?

回答by Madara's Ghost

You set up a remote repository by doing the following:

您可以通过执行以下操作来设置远程存储库:

On the remote server

在远程服务器上

cd /some/path
mkdir my-project.git
cd my-project.git
git init --bare

Then, on the local machine (assuming there's already a repo there)

然后,在本地机器上(假设那里已经有一个仓库)

cd /my/project/path
git remote add origin ssh://[email protected]:/some/path/my-project.git
git push --all origin

回答by Rápli András

To change the remote that's not working, do

要更改不起作用的遥控器,请执行

git remote remove origin
git remote add origin ssh://...

Also, restart Webstorm/PHPstorm to invalidate cached settings, otherwise it wouldn't work.

另外,重新启动 Webstorm/PHPstorm 使缓存设置无效,否则将无法工作。