Git工作流程 - 建立一个构建过程 [英] Git workflow - Setting up a build process

查看:180
本文介绍了Git工作流程 - 建立一个构建过程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

免责声明:我一直在使用Git,但仍然感到困惑。



我为一个项目设置了一个构建过程,并且正在运行更新git仓库的问题。


  1. 我在服务器上创建了仓库,可以说C:\ MyProject。 $ b
  2. 我使用SourceTree将我的电脑连接到存储库。做一个拉,并得到我所有的代码,一切都很好。

  3. 我去做一个提交,但得到一个错误说:拒绝更新签出分支...默认情况下,更新非裸存储库中的当前分支被拒绝

  4. 使用Google一点,我意识到服务器上的git存储库不应该有检出的主,所以我使用使用从本地分支中分离选项进行Git GUI结帐。这将服务器上的分支设置为HEAD。

现在是我困惑的部分(让我知道我是否真的早些时候感到困惑,只是不知道它)。推荐更新服务器上的代码的方法是什么?如果我在Git GUI中打开服务器存储库,则无法执行提取操作。什么似乎工作是如果我结帐主,但实际上是什么建议?如果是这样,那么这意味着我必须在每次更新后检出一个不同的分支,以便我可以继续在我的工作计算机上进行推送。 解决方案

推送到裸露的repo 是最佳实践:请参阅在git中裸共享仓库的概念所有关于裸回购 - 什么,为什么,以及如何解决非裸推



这意味着在您的服务器上,您需要:


  • 创建一个Git仓库(你已经做到了)

  • 克隆那个仓库回购仓库( git clone --bare yourProjectFolder yourProjectFolder.git )<
    .git 扩展是裸露回购根文件夹的命名惯例)

  •  <$ c  
  • $ c> git remote set-url origin /url/repo/repo/yourProjectFolder.git


  • 在bare repo中添加一个钩子(在服务器上, yourProjectFolder.git / hooks / post-receive ),其中


    • 更改目录(至您的非裸回购文件夹 yourProjectFolder

    • unset GIT_DIR

    • git pull ../ yourProjectFolder.git



    • $ b

      详情请参阅远程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.

      1. I created the repository on the server, lets say C:\MyProject.
      2. I connected my computer to the repository with SourceTree. Do a pull and get all my code, everything is great so far.
      3. I go to make a commit but get an error saying: "refusing to update checked out branch... By default, updating the current branch in a non-bare repository is denied"
      4. Use Google a bit, and I realize that the git repository on the server shouldn't have master checked out so I use Git GUI checkout using the option to "Detach from Local Branch". This sets the branch on the server to HEAD.

      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:

      • create a Git repo (you already did)
      • clone that repo a bare repo (git clone --bare yourProjectFolder yourProjectFolder.git)
        (the .git extention is a naming convention for bare repo root folder)
      • push to that bare repo instead:
        Go to your local repo, and type:

        git remote set-url origin /url/repo/repo/yourProjectFolder.git
        

      • add a hook in the bare repo (on the server, yourProjectFolder.git/hooks/post-receive), in which you

        • change directory (to your non-bare repo folder yourProjectFolder)
        • unset GIT_DIR
        • git pull ../yourProjectFolder.git

      See more at "Remote nodejs server deployment with forever".

      这篇关于Git工作流程 - 建立一个构建过程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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