jeyko
jeyko

Reputation: 3633

Git: two parallel branches with all files the same, except one different file (no .gitignore)

Information

The front-end of my website has:

The file vars.js contains

var server = 'localhost:3000';
export {server};

I want my production branch to contain

var server = 'https://servername.com/';
export {server};;

Question

Can I push to both branches, while keeping these files independent without using .gitignore?

Upvotes: 0

Views: 88

Answers (1)

Luke Hutton
Luke Hutton

Reputation: 10722

I usually have the following setup, a file for each environment, stored in each branch

  • vars.js - local variables
  • vars.production.js - production variables

Then my build process to deploy to production on CI/CD will replace vars.js with vars.production.js i.e. current build branch = production

One possible way to do it

Upvotes: 3

Related Questions