使用 post receive hook 推送到 DEV 服务器效果很好 - 但随后无法提交远程更改

发布于 2024-12-19 02:08:22 字数 388 浏览 4 评论 0原文

对 git 非常陌生,经过一番阅读后设置了以下工作流程:

  • Github 存储库

  • 本地存储库(工作站和笔记本电脑)

  • 开发服务器 - 将接收挂钩从裸存储库推送到提供文件的目录

这一直工作得很好,但今天我想要提交所做的更改开发服务器,然后将它们拉回到本地。

但是当我尝试暂存并提交更改时,我收到错误:“致命:不是 git 存储库...”

我想我明白为什么(因为包含所有文件的目录不是 git 存储库)但是如何我要在 DEV 服务器上提交更改并将它们拉回本地吗?

任何帮助将不胜感激 - 我是一名设计师,所以你可能需要简单地解释一下这一点。

干杯

Very new to git and after a bit of reading have setup the following workflow:

  • Github repo

  • Local repos (workstation and laptop)

  • Dev Server - post receive hook pushes from a bare repo to the directory where files are served

This has been working great but today I wanted to commit changes made on the dev server, then pull them back locally.

But when I tried to stage and commit the changes I received the error: "fatal: Not a git repository..."

I think I understand why (because the the directory containing all the files isn't the git repo) but how would I go about committing changes on the DEV server and pulling them back locally?

Any help would be much appreciated - I'm a designer so you might have to explain this simply sorry.

Cheers

Ben

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

横笛休吹塞上声 2024-12-26 02:08:22

我不完全确定你的设置是否是一个好主意 - 拥有更多克隆很便宜,并且避免做任何奇怪的事情。

编辑:以前我建议使用 --git-dir 选项,但这不起作用,因为存储库仍然是空的,而且 Git 知道这一点。您可以通过一些黑客技术来解决它,但最好的办法可能是创建一个非裸克隆,将更改的文件复制到其中,提交并推回。通过在您需要的地方实际拥有完整的存储库,您可以在将来省去麻烦。

I'm not entirely sure if your setup is a good idea - it's cheap to have more clones, and avoid doing anything weird.

Edit: Previously I'd suggested the --git-dir option, but that won't work, since the repo is still bare, and Git knows it. You could work around it with some hackery, but the best thing is probably to make a non-bare clone, copy the changed files into it, commit, and push back. You could save yourself the trouble in the future by actually having a full repo where you need it.

冷了相思 2024-12-26 02:08:22

要将任何内容提交到 Git 中,它需要是一个 git 存储库。

将 git 存储库克隆到您所服务的服务器中,而不是通过 ftp、sftp、rsync 或您可能使用的其他类似替代方案之一,并为每次更新执行 git pull

这样,您可以从服务器提交并推送到 github。

Git pull 是非常理想的,甚至可以减少需要传输到服务器的数据量。不仅如此,在服务器上拥有 git 存储库总是一个好主意,因为您可以在不到一秒的时间内使用单个命令切换分支、标签并移动到历史上的任何时间点。

To commit anything into Git, it needs to be a git repository.

Clone the git repository into the server from where you are serving, instead on ftp, sftp, rsync or one of the other similar alternatives you may be using, and for each update do a git pull

That way, you can commit from the server and push to github.

Git pull is very optimal and even reduces the amount of data that needs to be transferred to your server. Not just that, it is always a good idea to have the git repo on your server, as you can switch branches, tags and move to any point of time in history with a single command, in a fraction of a second.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文