I've branch out client branch (C) from main product (P) branch which I am adding features as per request. The main product branch contains all folders/files for every client with the main product code. Is there a way to delete and stop tracking other clients' folders in branch C but can still merge C to P without P removing the folders?
I've tried git rm
for the unwanted folders and adding them in .gitignore in C branch, but when I try to merge P is deleting them as well.
What you are looking for is sparse checkout.
git-scm.com/docs/git-sparse-checkout – eftshift0
git sparse-checkout set <unwanted-folder>
This resolved my issues since it stops tracking unwanted folders on my checked-out branch but kept them on remote product branch.
git sparse-checkout disable
to disable this configuration on my local environment