I'm not new to git, but not quite sure about this: I have worked on a project and want to tag the first release in the near future. Currently I'm only using the master branch. I noticed that I implemented a feature which is not good enough to be released with the oncoming release. Let's say the feature is located in a subfolder of my project root, what would be the best way to save that feature for a later release? Create a new branch derived from master and delete the feature from the master branch to merge it back later? Or are there some better tricks to do this?
-
Your first intuition is most likely the best route. – marcusshep Aug 22 '17 at 20:35
-
1Are there any commits that touch both the subfolder and the rest of the repository, or is the work on the new feature entirely self-contained? – jwodder Aug 22 '17 at 20:36
-
Yes, there are commits touching the subfolder and some other parts of the repo. I planned this feature to be part of the core, but later decided to remove it because it isn't in a state where I feel comfortable releasing it. – LuMa Aug 23 '17 at 21:09
2 Answers
You should create a new branch. That is the best way to use git. Whenever you add a new feature, the best approach is to make a new branch. That way, you keep your modifications separate from the master, and can later merge when the feature is acceptable. Should it not be acceptable, you just don't merge it, and you have a sort of isolation between your features.
Now this method would possibly lead to multiple development feature branches. Fear not, if there is a conflict while merging, you can always manually merge the files. More often, this won't be a case since new features require new files, new blocks of codes, and rarely edit the existing code. (If you have a good application structure, MVC for example, you won't be dealing with a lot of conflicts)

- 862
- 2
- 8
- 25
If you do not like to create new branch, you can use git revert
, which will create a new commits to reverse the effect of some earlier commits.
When you want to restore those reverted commit, you can refer to How do I “un-revert” a reverted Git commit?.

- 3,507
- 2
- 19
- 23