简体   繁体   English

如何在服务器上推送 git

[英]how to git push at server

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. Git 拒绝推送。 How can I update files in the server?如何更新服务器中的文件?

$ git push
To ssh://erkin@mornehir.com/~/erkin
 ! [rejected] master -> master (non-fast-forward)
 error: failed to push some refs to 'ssh://erkin@mornehir.com/~/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.

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 -u 将确保您可以稍后推送

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希望这可以帮助

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. ...然后再次尝试推动。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM