因为开发现场跟部署的环境不同,有很多ip地址每次都要改来改去;于是开两个分支master(用来保存部署现场的ip)和dev(开发环境的ip),开发功能时在dev分支,然后使用master合并,每个分支都保存着自己的config配置文件,不想dev分支被master合并时config文件也合并.

  1. 创建自定义merge driver
git config --global merge.ours.driver true
  1. 在要被merge的分支上创建.gitattributes文件,并且在文件中置顶不merge的文件名
echo 'config.js merge=ours' >> .gitattributes
git add .gitattributes
git commit -m 'chore: Preserve config.js during merges'  //只是为了commit代码,可以
  1. 回到要合并到的分支master,执行merge:

git merge dev

dev分支上的config.js就不会被合并了;


原文链接:https://www.jianshu.com/p/09b546b936a7

相关文章:

  • 2022-02-07
  • 2022-02-07
  • 2022-12-23
  • 2021-10-04
  • 2022-02-07
  • 2022-12-23
  • 2022-02-07
  • 2022-01-14
猜你喜欢
  • 2021-10-04
  • 2021-10-07
  • 2021-08-15
  • 2022-12-23
  • 2021-11-28
  • 2022-12-23
  • 2022-02-14
相关资源
相似解决方案