I have this particular scenario, which is simple really, but I don't see (so far) a similar question here.
I'm working in my own branch copied from a remote repo, And I have added my own tasks to a Capistrano Capfile. These tasks will only help Me deploy the app to my own private server, Therefore when it's time to Merge my branch with origin master, I don't want the changes in the Capfile to be pushed to the remote master repo, because, obviously, this file should remain intact over there without my personal alterations.
What's the best practice to deal with this situation?
Thanks in advance!
PS. I guess that what I'm looking for, is a way to 'Git Ignore' files exclusively for a branch. To over simplify things.
I would suggest to branch a now branch (lets name it Local
) off from your current branch (lets name it Original
).
In Original
, you revert the changes you made to the capfile. In Local
, you continue working on your data as usual. Before it comes to remerge into the remote, you merge Local
to Original
and just push Original
. If you do not change the local Capfile further, it should be fine, otherwise you have to (again) revert those changes (although that should result in a merge conflict anyways, so you can handle it in the merge directly).
See the bottom of the following page: https://git-scm.com/book/en/v2/Customizing-Git-Git-Attributes#_merge_strategies.
It describes how you can set different merge strategies with git attributes. In this case you always want the master version of your capistrano file to be in charge, not the one on your branch, e.g.
capistrano.file merge=ours
Ours refer to "our version of the file" relative to the branch you are on when doing the merge.