There may arise an occasion in which you need to revert a commit you have made to the Git repository used by Coalesce; e.g. code was promoted from your dev branch to your test branch before it was ready.
However, reverting the problem commit is not enough to reset your Git repository to your expected state. Instead, what you'll see if you simply revert is that when you go to reapply the changes once you've corrected your problems, your changed objects will not be in your change tracking list as you'd expect. What you have to do is actually revert the problem commit, and then revert your revert. While this seems logically counterintuitive, reverting the revert is necessary to rebase the history on your objects to the state it was in prior to your problem commit and ready the objects for re-commit at a later stage.
The following articles provide more information on why this in necessary when this occurs:
- Git - Revert The Revert
- How to restore changes which you’ve reverted from your main git branch
- Create Pull Request from a Reverted Git Branch
To apply this practice to Coalesce, you would need to take the following steps within a Git command line interface (CLI) on your local machine/a Git client:
1. Checkout the branch you wish to revert the commit on and pull by running the following scripts:
git checkout <brand_name>
git pull
2. Locate the commit ID of the commit you wish to revert and make note of it.
3. Revert the commit by running:
git revert <the commit ID you wish to revert> -m 1
4. Now, locate the commit ID of the revert you just completed in <your branch>, and execute the following script to “revert the revert”:
git revert <the commit ID of your revert you completed in Step 3> -m 1
5. Proceed with your development and code promotion as normal.