smeeb
smeeb

Reputation: 29477

Purging old directories and files from a remote hg repo

I initially committed my project to a hg repo with the following structure:

myapp/
    fizz/
        buzz.txt
    foobar.cfg
    whistlefeather/
        vroom-vroom-party-starter.xml

I did so using the following commands:

hg add
hg commit -m "Initial commit."
hg push

I then changed my directory structure locally to look like this:

myapp/
    buzz/
        fizz.txt
    config.foobar
    whistlefeather/
        vroom-vroom-party-starter.xml

I then ran the same following commands:

hg add
hg commit -m "Changing some things."
hg push

When I go to the remote repo, I see it has the following structure (?!?):

myapp/
    fizz/
        buzz.txt
    buzz/
        fizz.txt
    foobar.cfg
    config.foobar
    whistlefeather/
        vroom-vroom-party-starter.xml

What commands can I run to push/purge the old directories/files from the remote repo (and so that it reflect the directory struture on my local machine)?

Upvotes: 0

Views: 25

Answers (2)

planetmaker
planetmaker

Reputation: 6044

It's actually simple to remember:

  • hg add adds files to the repo
  • hg remove removes files
  • hg move moves or renames files
  • hg addremove looks at current working dir and adds and removes files from the repo such that only the files still being present will continue to be tracked.

Each of these operation can be done in any sequence. And only a commit will actually create a changeset

Upvotes: 0

Anton Gogolev
Anton Gogolev

Reputation: 115691

The hg add command you issued prior to your second commit did not actually remove files from under version control, but only added new ones. Now your repository is actually a melange of old and new files.

To add new files and remove missing ones, use hg addremove command or hg commit -A

Upvotes: 1

Related Questions