1

Question regarding Git best practices. When making a major new version of a project (in my case it's a Codeigniter project) I am faced with two options:

  1. Create a new branch (e.g. branch version2)

  2. Create a copy of existing project folder and make it a new git project.

Advantage of 1): development may be ongoing for version1 branch, so it will be easier to merge them at the end.

Disadvantage of 1) (and therefore advantage of 2)): version2 will be using an entirely new database, and will (at first) be hosted on a different staging server. Since my config files are not part of the repository, each time I want to switch between branches I'll have to manually edit the database config file.

Chris Martin
  • 28,558
  • 6
  • 66
  • 126
GluePear
  • 5,766
  • 10
  • 51
  • 95

3 Answers3

0

You should probably create a new branch and if you don't want to manually edit the database config file each time, you have the possibility to clone several times your project. Hence, merging the two versions will probably be easier than solution 2).

L. Meyer
  • 2,531
  • 1
  • 20
  • 23
0

If you are using Github/Bitbucket/VisualstudioOnline or any other service like this, I would use Forking instead of branching, the difference between branching and forking are mentioned in this SO's question but it is important to state this few things here:

  • If you are working in version 2 You won't be able to push changes directly to version 1 repo but you would need to create a new Pull request.
  • To keep the version 2 repo up to date with the original one, You will need to either add the original repository as an additional remote repository on your local repository or use Github sync tool.
Community
  • 1
  • 1
gerosalesc
  • 2,613
  • 3
  • 21
  • 41
0

As you are talking about GIT best Practices, I would like share your some of my points.

  1. All files should be present in Git repository( As currently, your database config files are not stored in GIT Repository)
  2. No Branching workflow is used ( Currently no branching workflow is followed by you which is not correct)

Solution:

  1. Git Should contain all files(Even your database files)
  2. Feature branch workflow should be used.

Feature branch workflow provides solution to both your problems , where you can create new release branch and deploy it to N1 server and release branch 2 to N2 server with different databases.

Also as CodeIgnitor is used you can define N number of environment and specify your settings within it. This will help you to specify different databases for different servers/environments.

Abhijeet Kamble
  • 2,753
  • 1
  • 25
  • 35