Search code examples
gitgitlabgitlab-cigit-merge

How to skip some file during merge request on gitlab


I am having two branches on GitLab(1.Staging & 2.Production). In my Angular and NodeJS application there is one part(e.g. Contact us ), which I don't want to deploy on production.

I want it in staging branch but not in production branch.

So my question is how can I skip the specific code during merging of two branches in GitLab.

I am using Merge requests button for merging. but I have .gitignore, .gitattributes & .gitlab-ci.yml files.

Please help me, Thanks in advance


Solution

  • As explained here, there is no obvious way to have a file in one branch, but not (after a merge) in another.

    If you can have that same file in both branches, but with a content (in prod) which would not be impactful, then you can put a merge driver in place in order to keep that prod content whenever you merge from staging.
    However, this is a local solution, not one you can set when clicking Merge directly on GitLab.