我需要git push to remote,而push需要是当前的工作副本.因为,推送源是一个Web主机.因此,推送的文件当前需要使用.我相信没有人会在主机上编辑文件:)
这个问题是这两个问题的后续问题, 是否有可能在另一个git repo中有一个git repo,并且在启动git repo时有什么区别--bare switch会做什么?
编辑:裸仓库不是我想要的,因为文件需要直接在远程机器上使用,需要在我放置它们的位置找到.
Edit2:据我所知,裸仓库不保留文件hieararchy,并在根目录中保存repo数据
she*_*mer 10
以下是如何在您的Web主机上创建一个允许直接推送的git仓库,将其设置为本地仓库的远程仓库,并推送更改的步骤.请注意,您需要具有对Web主机的ssh访问权限,并且已安装git.
在您的网络主机上(ssh'd in):
# create an empty repo on your web host; note its path
mkdir site
cd site
git init
# configure it to allow pushes to the current checked-out branch
# without complaining (direct push)
git config receive.denyCurrentBranch ignore
Run Code Online (Sandbox Code Playgroud)
现在使用您的本地repo(在repo中运行这些git命令):
# create the reference to the web host remote for pushing
# /path/to/the/repo is the path to the repo you made above on the web host:
# it will be an absolute path OR relative to your ssh chroot (depends on the host)
git remote add deploy ssh://your_user@your_host/path/to/the/repo
# finally, push your changes!
git push deploy master
Run Code Online (Sandbox Code Playgroud)
现在,您的更改已被推送到Web主机上的签出仓库.但是,它们不会反映在工作目录中(即,您的更改不会立即生效).这是因为您已直接推送到活动分支.要完成,你需要
git checkout -f
以更新工作目录git post-receive
钩子来自动完成.要使用post-receive
钩子进行即时自动部署,请查看此git站点部署方法.
归档时间: |
|
查看次数: |
8338 次 |
最近记录: |