29

I have a game project that will have two versions:

  1. A simple version of the game, the core.
  2. An advanced version of the game.

I have the 1st version in my public repository, and only I will be working on it. As for the 2nd version, two friends of mine and I will work on it. The crucial part is that I want the two versions to stay in my repository.

I thought I might use branches for this, but considering this question and its answer, it's not good practice to do so in terms of versioning. As far as I've found out, forking your own repository is not possible.

What are my options here? How can I keep both versions in my repository?

Varaquilex
  • 534
  • 2
  • 5
  • 14
  • 3
    A fork is a branch, just stored in another spot. –  Apr 29 '14 at 20:23
  • 1
    @MichaelT Ok. Are forks meant to be merged at some point, like branches? – Varaquilex Apr 29 '14 at 20:24
  • 23
    Fork is a github concept, not a git concept. It simply clones and puts it in your account. So cloning is what you're looking for. See http://stackoverflow.com/questions/6286571/git-fork-is-git-clone – pdr Apr 29 '14 at 20:24
  • @Varaquilex Way would you need to keep both versions in a single repository? Also `fork`ing a repository will create a new repository in your account. – Mahdi Apr 30 '14 at 16:50
  • 1
    Why not just have one version that can run in simple mode or advanced mode? Of course some parts of the code would only be active in simple and some parts only active in advanced, but I imagine a lot would be shared. – bdsl Aug 15 '17 at 23:44
  • @pdr forks are a bit more than just clone. In particular GitHub treat forks in a special way, that is they allow pull request from forks (and not from generic clones) and allow you to navigate all forks to a specific project. – pqnet Mar 08 '18 at 00:00

3 Answers3

15

To me it seems that you need two Repositories not two Branches. A branch is a mechanism to handle the changes within a single repository in order to eventually merge them with the rest of code.

If you really want to keep both versions of a Similar code-base in the same repository, then your only option is to go for a Branch, however as mentioned earlier, the main purpose of a branch is to separate some specific commits in a way that they don't conflict with the rest of code during the development period, and merge them when they are ready to go.

There are situations that a repository has two slightly different branches -- e.g. 32-bit and 64-bit versions of the same source-code, however I'd still recommend you to go for separated repositories, if that's an option.

Mahdi
  • 1,983
  • 2
  • 15
  • 25
10

The answer to the question "should I clone or fork" is exactly the same as the answer to this question "do I want my own personal version of this project?" yes = fork, no = clone the repository.

In git, branch is a light weight thing that is often temporary and may be deleted. A fork (on github) is a new project that is based on a previous project. You clone a repository to do work on it as a team member.

Many public projects have you fork the project to keep the working changes out of the main project.

For phase 2, fork the project then clone it to your working computer and have your friends do the same.

DwB
  • 672
  • 3
  • 7
  • How can I fork my own project? – Varaquilex Apr 30 '14 at 16:22
  • select the repository in github then click fork (button in top right for me) – DwB Apr 30 '14 at 16:24
  • I know how to do that, the thing is when you try to clone your own project, you are simply redirected to the repository, like you pressed refresh button. There are no additional repositories are listed when you browse your repositories after you try to fork your own project. I think I'm gonna make a new repo, copy the contents of the other repo which I want to fork and continue working with other people there. – Varaquilex May 02 '14 at 10:48
3

What it really sounds like you want is a submodule. If you create the first repo (your private simple repo) and then add it as a submodule to the advanced version repo, then you should be able to track and pull changes to the submodule in the advanced repo as you develop the private simple repo.

  • 1
    Several people have taken the time to -1 Ryan's response, but not taken the time to provide a comment why, and this behavior goes against the spirit of SO's guidelines. If in the OP's question, "core" were identical in both trees, having both a "simple" and "advanced" wrapper around core, then this answer is at least reasonable. – Scott Prive Sep 14 '17 at 15:27
  • I've upvoted but he should probably include an explanation like yours that explains *why* a submodule would be good, and how it would work. Splitting the common code into a library that can be included as a submodule is a good idea, but without specifying that that should be done the suggestion of a submodule doesn't immediately appear to make sense. – Sean Burton Mar 08 '18 at 12:14