I have this kind of situation. I have 2 branches, master and develop.
On develop branch I have some file, lets say tools.js. If I need I change this file, commit it and push it to Github develop branch.
After everything is done I merge develop branch into master. There is no tools.js file on master branch and I want to keep it like that.
How do I skip some files during the merge?
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:
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'
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'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With