Since you only merge devlop
branch into master
branch (not opposite), then you can add .gitignore
file to ignore tools.js
in master
branch only. Detail steps as below:
1. Add .gitignore to ignore tools.js in master branch
git checkout master
touch .gitignore
echo 'tools.js' > .gitignore
git add .gitignore
git commit -m 'ignore tool.js in master branch'
Note: If you have already committed the tools.js
file in master branch, then use below commands to ignore the file in HEAD
version:
git rm tools.js --cached
git add .
git commit -m 'remove tools.js in HEAD version on master branch'
2. Delete tools.js during merging develop into master branch
After ignoring tools.js
file in master
branch, you can merge develop
branch into master
branch. And there will has merge conflict for the file tools.js
during merging. And you can use below commands to resolve merge conflicts:
git rm tools.js
# modify and save other conflict files if there has
git add .
git commit -m 'merge develop branch into master branch'