0

If I want to refactor the legacy code then I need write tests for the code.So I make a new branch called 'refactor'.I will make a tests folder and some tests file in it.

But I found that when I finish the refactoring and want to merge to the master branch I need to merge tests folder and its files to master branch.

I do not want to merge these tests files to my master branch.

I want to keep the tests file and some other dev folders for the 'refactor' branch.Because maybe I need to fix some bug under this 'refactor' branch with those files.

How should I do?

macc
  • 105
  • 9
  • Do you need to keep them? (this i a basic git-usage question, and probably duplicate) – New Alexandria Jun 07 '17 at 15:39
  • I want to keep the tests file and some other dev folders for the 'refactor' branch.Because maybe I need to fix some bug under this 'refactor' branch with those files. – macc Jun 07 '17 at 15:44
  • Probably this topic is what you're looking for: how to ignore files in git https://stackoverflow.com/questions/8527597/how-do-i-ignore-files-in-a-directory-in-git – New Alexandria Jun 08 '17 at 12:55
  • You just need to put the files in the `.gitignore`. [See this Q&A](https://stackoverflow.com/questions/8527597/how-do-i-ignore-files-in-a-directory-in-git) – New Alexandria Jun 08 '17 at 12:56

1 Answers1

0

From master:

git merge --no-commit refactorbranch
git reset path/to/my/unwanted/tests
git reset path/to/unwanted/data
git commit -m "Merged refactoring"
Alejandro C.
  • 3,771
  • 15
  • 18