MartinP
MartinP

Reputation: 3

Git with separated development and releases

I need to help with Git configuration. I have a project and I would like to separate its development from its releases. The target is:

  1. No one except me can view or edit development code.
  2. Everyone (= public) can view the released code but no one except me can edit that.

How should I set repositories, branches, etc.? How should I commit releases?

(The solution shouldn't be based on user accounts because my Git hosting is limited in this.)

Upvotes: 0

Views: 54

Answers (1)

kan
kan

Reputation: 28951

  1. Until you publish your work, it is your private. Just don't push while developing. However, you could set-up a private repo visible to you only (e.g. just for backups or working from different locations such as laptop, desktop, etc).
  2. Set up another shared repo (e.g. on github) and push here only when you release.

Small demo:

[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.

Set up public repo in you wc

[kan@altegom so18334364]$ cd wc
[kan@altegom wc (master)]$ git remote add pubrepo /tmp/so18334364/pubrepo/

Doing development...

[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

Pushing into 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

Doing more development...

[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

now release is ready. Publishing it for public:

[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

Upvotes: 1

Related Questions