如何在服务器上进行git推送
在服务器中我创建了存储库。 我在家里的电脑上拉。 现在我做出了改变并且它们正在发挥作用, 我需要推送到服务器。 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您从主存储库克隆,请确保您已设置远程。因此,在您的主存储库中,您将:
现在您应该能够使用以下命令进行推送:
-u 将确保您稍后可以使用以下命令进行推送
如果您克隆并且没有创建裸存储库,请再次执行此操作,这次包括裸选项。
这将确保您可以在没有警告的情况下进行推送。非裸存储库将有一个工作目录,并且不喜欢被外部力量更改。
希望这有帮助
make sure you have the remote set up if you cloned from the home repo. So in your home repo you would:
now you should be able to push with:
the -u will make sure you can push later with just
If you cloned and did not make a bare repo, do it again and this time include the bare option.
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
该错误本质上意味着本地存储库中的历史记录不包含远程存储库中的历史记录。尝试:
...然后再次尝试推动。
That error essentially means that the history in your local repository doesn't contain that in the remote repository. Try:
... and then try pushing again.