Title: What is the best way to keep only related files to change in the git branch
Tags: html;git;github
Question: In my project, the number of HTML files are growing. How will I temporarily remove all the files which are not going to be changed in the git sub branches?
My problem is that when I merge it with the master branch, the files then got removed in the master too.
Comment: This sounds like a bad and non functional idea.  If you remove a bunch of HTML files then how will the site even run?  Just keep an eye on the pull requests and make sure no one changed a file not in scope for that task.

Comment: This is an atypical approach to things.  Just setup a demo which excludes those files. Perhaps you could disable certain links.

Comment: Your question is bit confusing, how the files are deleting itself? you created your project and add it to GitHub. Now when you add new files and new code lines `git add -A` this will track all the new changes and files and you just pushed them to live GitHub.

Comment: My intention is to keep only related html files in the specific branch. That will make showcasing to the client easier.

Comment: But this is a very early stage of development. Not deployed on the server yet. I used to just send the git zip download link and they preview the file.

Comment: My intention is that I have a files A,B, and C. I need to add a feature in C. For that, I created a new branch called feature1 and edit the file there. But What I want is that A and B should not be there in the feature1 branch but remain in the master branch. That would make the workspace cleaner and easier to search files plus easier to showcase it to the client for that specific feature that has been implemented recently.

Here is the accepted answer: This is not how git is supposed to work. Therefore, as others have suggested it's not advisable. Having said so and considering that git is not designed with such capability, there are a couple of ways to achieve what you want to do. But again, it might not be a smooth quick process given that this is something that is not desirable long term to manage a project.
Method 1 (smoother)
create your new branch and start working on it git checkout -b branch_name
first thing to do after creating new branch is to delete ALL your files that you don't want on this branch and then commit. As every commit, this will generate a hash (e.g. 4f8046) that identifies it. The hash can be found with the command git log.
Continue with your workflow and commits as usual. Showcase to your clients etc.
Before merging to master, undo the commit where you deleted the other files that are still on master, so that when you will merge the unmodified files will be kept there. do this with git revert <commit_hash&gt; therefore in this example git revert 4f8046.
merge your code in master.
Example: if git log outputs something like:
commit a3712a
Author: developer 1
Date:   Thu Jul 16 18:00:00 2017 +0100
Feature 2
commit 66e427
Author: developer 1
Date:   Thu Jul 16 17:00:00 2017 +0100
Feature 1
commit 4f8046
Merge: 4f6e4e9 030a11c
Author: developer 1
Date:   Thu Jul 16 16:00:00 2017 +0100
Deleted Files that I don' want on this branch
Then you will use git revert 4f8046 (to reintegrate deleted files) and then git merge master.
Method 2
A second approach is to use git cherry-pick which is the opposite of git revert. This commands lets you pick a specific commit and apply it to the current branch (therefore manually applying the commits from your branch to master). However, this would entail not merging the new branch into master:
Create your new branch and start working on it git checkout -b branch_name
Delete your files that you don't need on this branch and commit. You can do this even in multiple commits. Just make sure that enhancement/feature and deletion of files that you don't want on this branch are in separate commits
Make modifications to your files in this separate branch, trying to keep the number of commits small.
Save the hash of all the commits that you would like to apply from this branch to master (i.e. all the features that you created). Again, git log will print all commits and their hashes.
Go back on master git checkout master
Using git cherry-pick apply all the commits chronological order to master.
Example: if git log outputs something like:
commit a3712a
Author: developer 1
Date:   Thu Jul 16 18:00:00 2017 +0100
Feature 2
commit 66e427
Author: developer 1
Date:   Thu Jul 16 17:00:00 2017 +0100
Feature 1
commit 4f8046
Merge: 4f6e4e9 030a11c
Author: developer 1
Date:   Thu Jul 16 16:00:00 2017 +0100
Deleted Files that I don' want on this branch
Then you will go on master and use the commands git cherry-pick 66e427 and git cherry-pick a3712a in this order (cronological), and omitting the commit in which you deleted the files to be kept on master.
This assumes that the files modified with features are still in master and have not been modified further on master (so that cherry-pick will not generate a conflict).
Comment for this answer: Thanks. Best answer so far.

Here is another answer: Keeping only certain files per branch is not a best practice; there is no "best way" to do it.
You mention that the idea is to provide subsets of the files in client demos.  That suggests perhaps they're for different projects and should be in different repos.  If there are other scenarios where you need to coordinate across repos, you could consider using submodules.
If really it is better to think of them as one project - e.g. maybe changes are typically coordinated across multiple sets of files - then you should find a different solution for creating your demo packages (perhaps with a suitable build tool)
Comment for this answer: Hmm... downvote without comment, must mean someone thinks my answer is incorrect.  So I should expect to see them posting a superior answer momentarily, eh?  Not holding my breath.  Like 'em or not, the facts is the facts.
Comment for this answer: I am curious that git would already support such urodriguez@example.net. But based on the answers, it seems that I need to look to different solutions.

{'source': 'StackExchangeDataset', 'subset': 'stackoverflow.com', 'metadata': {'AnswerCount': 2, 'CommentCount': 6, 'ContentLicense': 'CC BY-SA 3.0', 'CreationDate': '2017:00:08/10/17', 'FavoriteCount': None, 'PostTypeId': 1, 'Tags': '<html><git><github>', 'Title': 'What is the best way to keep only related files to change in the git branch', 'ViewCount': 60, 'id': 45612504, 'user_AboutMe': '', 'user_AccountId': 6637147.0, 'user_DisplayName': 'Lalnuntluanga Chhakchhuak', 'user_Reputation': 568.0, 'user_Views': 99.0, 'user_id': 5123982.0}}