dagda1
dagda1

Reputation: 28770

git move folder one level down and maintain history

I want to move:

./frontend to ./frontend/application

But when I do git mv -v * ./application from ./frontend

I get this error:

fatal: can not move directory into itself, source=frontend/application, destination=frontend/application/application

But when I do mv -v * ./application I get the result I expect.

Upvotes: 1

Views: 745

Answers (1)

zigarn
zigarn

Reputation: 11595

By doing git mv -v * ./application, the * is expanded as all the files in the current folder, application included.
Git doesn't like to move a folder into itself, but mv handle it fine.

You have 2 solutions:

  1. Exclude application when using git mv:

    git mv -v !(application) application # in bash
    
  2. Move on the filesystem, then index with git:

    mv -v * application
    git add .
    # Git will detect the move
    

Upvotes: 6

Related Questions