I need help with a shell script to revert multiple commits in a new branch, then merge the result with one of existing branches. I have 3 branches in my project: dev, live and stage. stage branch is for changes which are testing on stage website, then, after client's approval, they should go to the live branch.
The problem is that the client may not approve all stage changes for deployment (for example, I've done 1,2,3,4,5 tickets each of which was commited in stage branch, but client approved 1,3,4 and requires immediate deploy). So, the task is to merge particular commits from the stage branch with live. My solution is:
- checkout new branch (deploy)
- revert commits I don't need in deploy branch
- merge deploy branch with live
So far I'm reverting changes in deploy branch manually. Now I want to automate this process and I'm trying to create a script for step 2(reverting particular commits in deploy branch). My script is:
git filter-branch -f --commit-filter '
if [ "$GIT_COMMIT" = "8f3859d5f1a5bb75d50f933a0277ba4bca4f2abc" ];
then
git revert $GIT_COMMIT --no-edit
git commit -m "Cleaning up revision: $GIT_COMMIT"
fi' HEAD
where in if clause I list all the commits that should be reverted. But after applying this script I always receive a message
Rewrite 8f3859d5f1a5bb75d50f933a0277ba4bca4f2abc (6/13)error: Your local changes would be overwritten by revert.
hint: Commit your changes or stash them to proceed.
But git status command shows, that there are no changes to commit. So, the main question is, why does it work when I execute commands manually but not when I isolate them within a script? P.S. I'm using Git for Windows