Git具有独立的开发和发布

时间:2013-08-20 11:55:05

标签: git configuration repository

我需要帮助Git配置。我有一个项目,我想将其开发与其版本分开。目标是:

  1. 除了我之外,没有人可以查看或编辑开发代码。
  2. 每个人(=公开)都可以查看已发布的代码,但除了我之外,没有人可以编辑
  3. 我应该如何设置存储库,分支机构等?我该如何提交发布?

    (解决方案不应该基于用户帐户,因为我的Git托管仅限于此。)

1 个答案:

答案 0 :(得分:1)

  1. 在您发布作品之前,它是您的私人作品。只是不要在开发时推动。但是,您可以设置仅对您可见的私人仓库(例如,仅用于备份或从笔记本电脑,台式机等不同位置工作)。
  2. 设置另一个共享仓库(例如,在github上),只有在你发布时才推送到这里。
  3. 小演示:

    [kan@altegom so18334364]$ git init --bare privrepo
    Initialized empty Git repository in /private/tmp/so18334364/privrepo/
    [kan@altegom so18334364]$ git init --bare pubrepo
    Initialized empty Git repository in /private/tmp/so18334364/pubrepo/
    
    [kan@altegom so18334364]$ git clone privrepo wc
    Cloning into 'wc'...
    warning: You appear to have cloned an empty repository.
    done.
    

    在你wc

    中设置公共回购
    [kan@altegom so18334364]$ cd wc
    [kan@altegom wc (master)]$ git remote add pubrepo /tmp/so18334364/pubrepo/
    

    进行开发......

    [kan@altegom wc (master)]$ echo test > file1
    [kan@altegom wc (master)]$ git add file1
    [kan@altegom wc (master)]$ git commit -m "development..."
    [master (root-commit) 14bf15b] development...
     1 file changed, 1 insertion(+)
     create mode 100644 file1
    

    推进privrepo

    [kan@altegom wc (master)]$ git push
    Counting objects: 3, done.
    Writing objects: 100% (3/3), 230 bytes | 0 bytes/s, done.
    Total 3 (delta 0), reused 0 (delta 0)
    To /tmp/so18334364/privrepo
     * [new branch]      master -> master
    

    进行更多开发......

    [kan@altegom wc (master)]$ echo test2 >> file1 
    [kan@altegom wc (master)]$ git commit -am "more development"
    [master b90983d] more development
     1 file changed, 1 insertion(+)
    [kan@altegom wc (master)]$ git push
    Counting objects: 5, done.
    Writing objects: 100% (3/3), 264 bytes | 0 bytes/s, done.
    Total 3 (delta 0), reused 0 (delta 0)
    To /tmp/so18334364/privrepo
       14bf15b..b90983d  master -> master
    

    现在发布已准备就绪。公开发布:

    [kan@altegom wc (master)]$ git push pubrepo master 
    Counting objects: 6, done.
    Delta compression using up to 8 threads.
    Compressing objects: 100% (2/2), done.
    Writing objects: 100% (6/6), 421 bytes | 0 bytes/s, done.
    Total 6 (delta 1), reused 0 (delta 0)
    To /tmp/so18334364/pubrepo/
     * [new branch]      master -> master