0

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

MartinP
  • 3
  • 2

1 Answers1

1
  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
kan
  • 28,279
  • 7
  • 71
  • 101
  • OK, two repositories (one public, one private) are good. How should I switch between them **and then switch back**? – MartinP Aug 20 '13 at 12:13
  • 1
    Where is no such thing in git as "switch". So I don't know :) Your local wc is also repository. You could set up several remotes here, one for public, another for private and choose where you push your changes. – kan Aug 20 '13 at 12:15
  • This is clear - two remote repositories. But what pattern should I use for releasing - "take a version and commit that to the public repository" (only released code is available for public - **version between releases are not**)? – MartinP Aug 20 '13 at 12:24
  • @MartinP I've added a small demo. Please play around and see how it works, then you could ask more specific questions. – kan Aug 20 '13 at 12:28