我如何:Git单向推/不可编辑工作目录? [英] How do I: Git One Way Push / Uneditable Working Directory?
问题描述
有没有两种机器的方法,比方说A和B.
是否有可能在没有 的情况下做任何 git pull
的任何事情?
我基本上只想使用git。在一个方向。有点像使用 rsync
将本地目录同步到远程目录,但使用版本控制。如果这对于git来说是不可能的,是否可以用其他方法?
再次,最好是使用版本控制。
这篇文章解释得非常好。我将从那里复制代码。
假设您在服务器和工作站之间设置了SSH身份验证(无密码)。
在服务器上:
mkdir website.git&& cd website.git
git init --bare
mkdir /var/www/www.example.org
touch hooks / post-receive
chmod + x hooks / post-receive
然后把这个放在hooks / post-receive
#!/ bin / sh
GIT_WORK_TREE = / var / www / www.example.org git checkout -f
在您的本地git存储库中:
git remote add web ssh://server.example.org/home/ams/website.git
git push web + master:refs / heads / master
配置:
Is there a way to have two machines, let's say A and B.
- A is my local machine, where I develop my code, and push it.
- B is a server, that will NEVER have to edit code, but NEEDS a working directory.
Is it possible to do this without doing any git pull
's whatsoever from B?
I want to use git one way only, basically. In one direction. Sort of like using rsync
to sync a local directory to a remote one, but with version control. If this isn't possible with git, is it possible with anything else?
Again, preferably with version control.
This article explains it very well. I'll copy the code from there.
It assumes you have SSH authentication set up (no password) between your server and workstation.
On the server:
mkdir website.git && cd website.git
git init --bare
mkdir /var/www/www.example.org
touch hooks/post-receive
chmod +x hooks/post-receive
Then put this in hooks/post-receive
#!/bin/sh
GIT_WORK_TREE=/var/www/www.example.org git checkout -f
In your local git repository:
git remote add web ssh://server.example.org/home/ams/website.git
git push web +master:refs/heads/master
Configuration:
- /var/www/www.example.org is the public root of this site.
- /home/ams is the location you created website.git
- server.example.org is the domain, IP, or host alias of your server
这篇关于我如何:Git单向推/不可编辑工作目录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!