Reputation: 3797
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?
Upvotes: 4
Views: 2516
Reputation: 6337
As you’ve described things, tools.js
is a build artifact, so it has no place in your Git repo at all. You’ll want to build it somewhere in your deploy process—if not on Heroku, then in Pipelines.
Upvotes: 0
Reputation: 38106
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'
Upvotes: 2