Hi,
Is there a way to remove a from a remote changeset, or to remove an entire changeset? I accidentely pushed a .war file to a remote repo and I want to remove it.
Thanks
Hi,
Is there a way to remove a from a remote changeset, or to remove an entire changeset? I accidentely pushed a .war file to a remote repo and I want to remove it.
Thanks
Mercurial tries very hard to keep your data safe, so you can generally not change history.
That being said, there are numerous extensions for Mercurial that allows you to quite easily change history anyway. There is a page on the wiki about editing history. That page also explains the consequences.
In your specific case, you have to ask yourself if others will have already pulled your changeset? If so, then even if you remove it, it will still exist in their clones and you might be better off with accepting the mistake.
If you decide to remove it, I suggest using hg clone
to get a copy without it. This is the safe way since it will always leave behind a backup. If you pushed [z]
to the remote repository:
[x] --- [y] --- [z]
and now want to remove it, then log into the server and do
hg clone -r y repo repo-without-z
Then repo-without-z
will contain all changests up till [y]
-- that is, [z]
will have been removed:
[x] --- [y]
You can then continue working and push a new changeset:
[x] --- [y] --- [w]
If I had pulled the [z]
changeset already and now pull [w]
I will see two heads in the repository:
[w]
/
[x] --- [y] --- [z]
This is not dangerous per se -- but people might be surprised. If I remove [z]
from my clone I will end up with the same repository as you. But, as wrote above, this might be impractical if you have many users.
You can also use the MQ extension to strip the changeset away in-place. That way you wont make a new clone.
Finally, if you're certain that the push was the very last operation done on the server, then hg rollback
can be used to remove the last transaction. But don't do this if you are the only one who can push to the repository, otherwise you might end up rolling back a different transaction.
If the repository is on Bitbucket, then you cannot log into the server. But Bitbucket has recently added a strip functionality to its web interface. Look for "Repository management" in the "Admin" section.
Seeing as I can't comment on the answer above (stackoverflow won't let me log in to my old account, as they only allow OpenID logins now):
Bitbucket does offer you a bundle (backup) upon stripping, and this does not count against your quota. The reason why it appears to do so, is only because we haven't invalidated the cache key specifying how much space you use.
This is a bug in our system, and will be remedied. Until then, rest assured that the changeset has been removed, and the backup is free :-)
I used hg mqueue extension to edit history. It seems that it worked. Thanks all.