Git工作流程 - 建立一个构建过程 [英] Git workflow - Setting up a build process
问题描述
免责声明:我一直在使用Git,但仍然感到困惑。
我为一个项目设置了一个构建过程,并且正在运行更新git仓库的问题。
- 我在服务器上创建了仓库,可以说C:\ MyProject。 $ b
- 我使用SourceTree将我的电脑连接到存储库。做一个拉,并得到我所有的代码,一切都很好。
- 我去做一个提交,但得到一个错误说:拒绝更新签出分支...默认情况下,更新非裸存储库中的当前分支被拒绝
- 使用Google一点,我意识到服务器上的git存储库不应该有检出的主,所以我使用使用从本地分支中分离选项进行Git GUI结帐。这将服务器上的分支设置为HEAD。
现在是我困惑的部分(让我知道我是否真的早些时候感到困惑,只是不知道它)。推荐更新服务器上的代码的方法是什么?如果我在Git GUI中打开服务器存储库,则无法执行提取操作。什么似乎工作是如果我结帐主,但实际上是什么建议?如果是这样,那么这意味着我必须在每次更新后检出一个不同的分支,以便我可以继续在我的工作计算机上进行推送。 解决方案
推送到裸露的repo 是最佳实践:请参阅在git中裸共享仓库的概念和所有关于裸回购 - 什么,为什么,以及如何解决非裸推。
这意味着在您的服务器上,您需要:
git clone --bare yourProjectFolder yourProjectFolder.git
)<
( .git
扩展是裸露回购根文件夹的命名惯例)
<$ c
$ c> git remote set-url origin /url/repo/repo/yourProjectFolder.git
在bare repo中添加一个钩子(在服务器上, 详情请参阅远程nodejs服务器部署与永远。 Disclaimer: I've been using Git for a while but still find it confusing. I'm setting a build process for a project and am running into a problem updating the git repository. Now is the part where I'm confused (let me know if I was actually confused earlier and just don't know it). What is the recommended way to go about updating the code on the server? If I open the server repository in Git GUI there is no option to do a fetch. What seems to work is if I checkout master, but is that actually what's recommended? And if it is, then that would mean I have to checkout a different branch after each update so that I can continue doing pushes on my work computer. It is a best practice to push to a bare repo: see "concept of bare shared repository in git" and all about "bare" repos -- what, why, and how to fix a non-bare push. Which means on your server, you need to: push to that bare repo instead: add a hook in the bare repo (on the server, See more at "Remote nodejs server deployment with forever". 这篇关于Git工作流程 - 建立一个构建过程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋! yourProjectFolder.git / hooks / post-receive
),其中
yourProjectFolder
)
unset GIT_DIR
git pull ../ yourProjectFolder.git
$ b
git clone --bare yourProjectFolder yourProjectFolder.git
)
(the .git
extention is a naming convention for bare repo root folder)
Go to your local repo, and type:git remote set-url origin /url/repo/repo/yourProjectFolder.git
yourProjectFolder.git/hooks/post-receive
), in which you
yourProjectFolder
)unset GIT_DIR
git pull ../yourProjectFolder.git