如何在服务器上进行git推送

发布于 2024-11-14 16:12:13 字数 726 浏览 4 评论 0原文

在服务器中我创建了存储库。 我在家里的电脑上拉。 现在我做出了改变并且它们正在发挥作用, 我需要推送到服务器。 Git 拒绝推送。 如何更新服务器中的文件?

$ git push
To ssh://[email protected]/~/erkin
 ! [rejected] master -> master (non-fast-forward)
 error: failed to push some refs to 'ssh://[email protected]/~/erkin'
 To prevent you from losing history, non-fast-forward updates were rejected
 Merge the remote changes before pushing again.
 See the 'Note about fast-forwards' section of 'git push --help' for details.

In server I created repository.
In home computer I pulled.
Now I made my changes and they are working,
I need to push to server. Git refused to push.
How can I update files in the server?

$ git push
To ssh://[email protected]/~/erkin
 ! [rejected] master -> master (non-fast-forward)
 error: failed to push some refs to 'ssh://[email protected]/~/erkin'
 To prevent you from losing history, non-fast-forward updates were rejected
 Merge the remote changes before pushing again.
 See the 'Note about fast-forwards' section of 'git push --help' for details.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

东北女汉子 2024-11-21 16:12:13

如果您从主存储库克隆,请确保您已设置远程。因此,在您的主存储库中,您将:

git remote add origin <url/file path to your other repo>

现在您应该能够使用以下命令进行推送:

git push -u origin master

-u 将确保您稍后可以使用以下命令进行推送

git push

如果您克隆并且没有创建裸存储库,请再次执行此操作,这次包括裸选项。

git clone --bare <file path or url to your home repo>

这将确保您可以在没有警告的情况下进行推送。非裸存储库将有一个工作目录,并且不喜欢被外部力量更改。

希望这有帮助

make sure you have the remote set up if you cloned from the home repo. So in your home repo you would:

git remote add origin <url/file path to your other repo>

now you should be able to push with:

git push -u origin master

the -u will make sure you can push later with just

git push

If you cloned and did not make a bare repo, do it again and this time include the bare option.

git clone --bare <file path or url to your home repo>

This will ensure that you can push without warnings. A non-bare repo will have a working directory and will not like having that changed by outside forces.

hope this helps

笛声青案梦长安 2024-11-21 16:12:13

该错误本质上意味着本地存储库中的历史记录不包含远程存储库中的历史记录。尝试:

 git pull

...然后再次尝试推动。

That error essentially means that the history in your local repository doesn't contain that in the remote repository. Try:

 git pull

... and then try pushing again.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文