如何直接使用push直接推送到远程服务器? [英] How push directly to remote server just using push?

查看:117
本文介绍了如何直接使用push直接推送到远程服务器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我得到了一个远程的 git 存储库,我将它克隆到我的本地存储库,进行了本地更改,当我推送时,我收到了无法推送到主分支的消息:
$ b

I got a remote git repository, I cloned it to my local repository, made local changes and when I push I got the message that I cant push to the master branch:


[远程拒绝] master - > master(分支目前已检出)

[remote rejected] master -> master (branch is currently checked out)

我读到,如果我改变了它的分支,我会这样做,但我不能这样工作。我需要的是,当我将更改从本地存储到远程存储库时,这些更改同时适用于远程存储库上的文件,我不想返回到master分支或合并分支。

I read that if I change the branch it works, I do it and works, but I can't work like that; I need that when I push changes from local to remote repository the changes apply in the same time to the files on remote repository, I don't want to return to master branch, or merge branches.

我也读过,我可以使用裸存储库,它不适用于我。

I read too that I can use bare repositories, it doesn't work for me.

我看到一些视频,其中的人直接推送到远程存储库只需要输入一个密码,但我不知道如何去做所有这些工作。

I see some videos where guys push directly to remote repository and just need to enter a passphrase, but I don't know how to do all that to work like that.

推荐答案

$

它应该可以工作。b $ b

我也读过,我可以使用裸存储库,它不适用于我。但是,如果您了解了使用Git管理网站中介绍的过程正在使用一个裸露回购(您推到),与一个后接收挂钩:

It should work for you though, if you get that the process described in Using Git to manage a web site is using a bare repo (to which you push to), with a post-receive hook:

$ mkdir /var/www/www.example.org
$ cat > hooks/post-receive
#!/bin/sh
GIT_WORK_TREE=/var/www/www.example.org git checkout -f
$ chmod +x hooks/post-receive

在您的情况中,优点是钩子可以检出您需要的任何分支。

The advantage, in your case, is that the hook can checkout any branch you need.

注意:密码可能与使用推送地址ssh one和使用私人密码保护的ssh密钥有关。

Note: the passphrase is likely related to using for a push address an ssh one, and using a private password-protected ssh key.

这篇关于如何直接使用push直接推送到远程服务器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆