I have the following git
workflow:
- Create new feature branch
- Work on feature branch
- Commit often
- Once feature is complete, merge into
master
branch - Rinse and repeat
However, sometimes, I have the need to revert a whole feature from master. This could involve a whole lot of revert
ing. (The reason for needing to revert a feature is I have a website that works off of one repo. From there, we use a script that deploys the site to either our Production site or Staging site. Both are done from our master branch. Don't ask, that's just what I've been given to work with. Sometimes, I'm working on something that I stage, but then an immediate change needs to be made, so I needed some way to pull my changes in order to clean the repo.)
I'm thinking that the easiest way to do so is if each feature branch has only one commit. Then I could revert
that commit. So naturally, I am thinking of squashing all commits of a feature branch into one, prior to merging it into master
.
So now my workflow would look like:
- Create new feature branch
- Work on feature branch
- Commit often
- Once feature is complete git rebase -i HEAD~number_of_commits (or if remote branch is available, origin/feature_branch)
Is there any issues with this logic? Does it go against any best practices? I did some testing myself and the whole workflow seems to run smoothly and solves my problem, but I wanted to run the idea by other (smarter) Git-ers to see if there is anything wrong with it.
Thanks!