简体   繁体   English

将Git与现有文件一起使用,并在推送后更新分支

[英]Use Git with existing files and update branch after push

we are currently starting to work with Git and run into some trouble. 我们目前开始与Git合作,并遇到了一些麻烦。

Baiscally what i want is to have a Git-Repository that users can push to and pull from. Baiscally我想要的是拥有一个用户可以推入和拉出的Git存储库。

Also this repository should work as Preview Version of the master branch, so we need to have the script files in the repository itself. 此外,此存储库还应作为master分支的预览版本,因此我们需要在存储库本身中包含脚本文件。

I initiated the repository with "git init test.git". 我使用“ git init test.git”启动了存储库。 So it's not a bare repo. 因此,这不是一个简单的回购协议。

Question is how to setup git that it holds the current version of the master branch as real files and i can setup a url to reach the current master branch of the repository. 问题是如何设置git,使其将master分支的当前版本保存为真实文件,并且我可以设置url以到达存储库的当前master分支。

When i create a repository and try to push to it i get an error that the current master branch is checked out on the repository and i cant push to it. 当我创建存储库并尝试将其推送到存储库时,我收到一个错误,即当前主分支已在存储库中签出,而我无法推送至该存储库。

Any ideas? 有任何想法吗?

You must not push to a non bare repository! 您一定不要推送到非裸仓库! You cannot push to a checked out branch! 您不能推送到已签出的分支!

Now given you situation my suggestion is: 现在给你的情况我的建议是:

Keep a blessed bare repository! 保留一个幸运的裸仓库! Do all your development on the local, merge/rebase on master and then push to blessed bare. 在本地进行所有开发,在master上进行合并/重新建立基础,然后再推向有福者。

You can write the post-receive hook of the blessed bare that it has a code/runs a script that has code to cd into your production repo, and pull from blessed bare.(it will be a fast-forward as you might have resolved conflicts before pushing to blessed bare) 您可以编写祝福的裸露的接收后钩子,说它有代码/运行一个脚本,该脚本的代码可以放入cd到您的生产仓库中,然后从祝福的裸露中拉出。(冲突,然后推向有福的人)

This way, on every push to 'blessed bare', you pull into the production and update the checked out master! 这样,在每次尝试“祝福裸露”时,您就可以投入生产并更新签出的母版!

Hope this solves the problem. 希望这能解决问题。

Happy gitting! 快乐的混蛋!

根据您的描述,我认为实施称为GitFlow的分支策略可能对您有用

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

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