简体   繁体   中英

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

Information

The front-end of my website has:

  • branch production
  • branch local
  • a file vars.js

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 ?

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 ie current build branch = production

One possible way to do it

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM