norand
norand

Reputation: 33

How to uncommit one file in a series of commits in TortoiseHG (Mercurial)?

Screenshot of repo

Hi,

I've just joined a new company, and they are using TortoiseHG for version control, but due to some IT restrictions have never got this setup properly (hopefully due to change soon). This means I have access to both local and remote files (just a mapped network drive).

In short, I have accidentally managed to commit a 1GB file (Rev 50, see screenshot). However, due to file size, this will not push to the server.

Is there a way I can go to Commit Rev 50, un-add the 1GB file - but keep the rest of the commits history up until Rev 63 (see screenshot) so I can push all to the Server?

Note the v0.0.1 of the software was a ~400MB file and hence why it committed fine with no issue, and hence both servers already have some "file.software" of ~400MB

I have tried manually copying and pasting the local files to the remote, but I ended up with a parent location of -1 (00000000).

I have also tried ignoring and deleting the file in a later commit, but as the push to the server is done in order it always hangs on the 1GB file.

A temporary solution would be fine, as hopefully, we are changing to a different version control system in the future like SVN.

Upvotes: 2

Views: 36

Answers (1)

StayOnTarget
StayOnTarget

Reputation: 12988

Here's a simple approach which doesn't assume any special HG configuration that I can think of. You may need to edit mercurial.ini and make sure rebase is enabled by adding:

[extensions]
rebase =

Commands:

hg update 49
hg revert 50
hg forget name-of-the-huge-file
hg commit

Explanation: this resets your working directory to the state of the commit prior to the one with the problem. Then it copies the changes from the problematic commit to the local directory. Finally it undoes the one problematic file by telling HG not to add it after all.

At this point your revision graph would be like this:

-49-50-51-....
   \
    50B

where 50B is just my made up name for the commit you just made.

Next is to move all the other commits from 50 to 50B.

hg rebase -s 51 -d 50B

afterwards the graph would be more like:

-49-50
   \
    50B-51-....

Finally you can remove the original 50 with hg strip -r 50.


hopefully, we are changing to a different version control system in the future like SVN

Nothing against SVN, but Mercurial is really an excellent and generally easy to learn & use source control tool. Don't let it being new to you become a barrier to learning more.

Upvotes: 1

Related Questions