在现有文件中使用Git并在推送后更新分支 [英] Use Git with existing files and update branch after push

查看:135
本文介绍了在现有文件中使用Git并在推送后更新分支的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



Baiscally我想要的是拥有一个Git-Repository,用户可以推送并拉动

另外,这个存储库应该作为主分支的预览版本,因此我们需要在存储库本身中包含脚本文件。



我使用git init test.git启动了存储库。所以它不是一个光鲜的回购。



问题是如何设置git,它将主分支的当前版本保存为真实文件,并且我可以设置一个url来达到

当我创建一个存储库并尝试推送它时,我得到一个错误,当前主分支已在存储库中检出,而我无法推送到它。



任何想法?

解决方案

不要推到非裸仓库!你不能推送到一个检出分支!



现在给你的情况我的建议是:



保持祝福裸仓库!在本地进行所有的开发工作,在主人身上进行合并/重新绑定,然后推送到幸运的裸体。



您可以编写它拥有的一个代码/运行一个脚本,该脚本的代码将 cd 放入您的生产回购中,并从幸运的裸机中取出(这将是一个快进,因为您可能已经解决了冲突通过这种方式,在每一次幸福裸露的推动下,您都可以进入制作过程并更新已签出的主人!

$ b



$ b

希望这可以解决问题。



快乐的按摩!


we are currently starting to work with Git and run into some trouble.

Baiscally what i want is to have a Git-Repository that users can push to and pull from.

Also this repository should work as Preview Version of the master branch, so we need to have the script files in the repository itself.

I initiated the repository with "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.

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.

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)

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!

这篇关于在现有文件中使用Git并在推送后更新分支的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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