While working with changesets in Kiln you have three options for reverting your changes. Depending on the repository you use, git or Mercurial, the commands you will use will be different. To make the explanation simple and use common wording, we grouped these three options in the following concepts:
If you want to scrap your local changes and want to get back to your last good commit use the following commands:
Any uncommitted files will be reset, letting you start coding again with a clean slate.
If you find a bug in a changeset that’s buried in your repository history, you want to undo that changeset by applying a new commit that’s the exact opposite of the old changeset.
To get the changeset ID, grab it from the URL in Kiln or from
git log or
hg log at the command line. Both commands work similar, except that with Mercurial, you also have to
commit after you run
One of the advantages of undoing a changeset versus modifying your repository’s history (by using Remove) is that the “undo changeset” becomes a part of your repository history. You make a mistake. You fix the mistake. It’s all tracked in version control. This is preferable to modifying (removing) history, which isn’t tracked.
Make sure you’re committing granular changesets. Meaning, if you have 3 different bugs to fix, each bug fix should be its own changeset. That way, if you need to undo one changeset, you can undo one without affecting the others.
Removing changesets from your repository should be considered only as a last resort because it changes the history of your modifications. If you simply wish to Undo the effects of a changeset, use
git revert or
hg backout instead (see Undo above).
The most common reason to remove a changeset from your history is that it contains sensitive information, e.g. passwords, tokens, etc.
When modifying the history of a changeset by removing some modifications, it is recommended that the removal should be done in all repositories where the given changeset has been pushed.
Removal - using Kiln Web Interface
Changesets can be removed directly from within Kiln by Stripping Changesets using Kiln's Web Interface. After the strip completes, make sure to perform the same strip locally or reclone the repository.
Removal - using git or Mercurial commands
Git and Mercurial don’t have exact equivalents of the strip in Kiln. Mercurial’s command is the same, but git is different.
^ in the git command, which indicates the parent of the specified changeset.
In Mercurial, you’re saying “remove this changeset and all its descendants”.
In git, because you’re targeting the parent of the changeset, you’re saying, “remove all the history of the descendants of the *parent* of the specified changeset”. Because of this, you could end up removing multiple branches if the changeset's parent has multiple lines of descendants.
For example, let’s say you wish to remove the following changeset (marked with the tag
Adam). Let's say this changeset has the following IDs:
- in Mercurial the changeset ID is
- in git the changeset ID is
In the screenshots below, the parts of the DAG outlined in blue for each image is the part that would be removed.
In Mercurial you remove only the changeset and its descendants:
hg strip ace5a7f8b03e
In git you remove all descendants of the parent (not just the given changeset):
git reset --hard 0733de811a74^
NOTE: You can also use
git reset --hard changesetId~1, which is the same as
git reset --hard changesetId^. If you’re using Windows command prompt, the
^ character won’t work. Consider switching to Powershell or use
- git rebase and hg histedit for more on modifying repository history.
- Remove sensitive data – a guide for how to remove an entire file from your repository history in git.