1

Is it possible to move/rename a folder in a post-receive (or any other hook) on a bare repository?

#!/bin/sh
mv /path/to/worktree/src /path/to/worktree/public

When I try to push to the repository I get an error:

remote: mv: cannot stat `/path/to/worktree/src': No such file or directory

I am sure that the folder exists in my local branch.

NinjaFart
  • 1,626
  • 1
  • 20
  • 24
  • 1
    Bare repository doesn't have a workdir, that's why it's called "bare". – kan May 18 '16 at 20:19
  • Oh, yeah of course. Later in `post-receive` I am calling `git --work-tree=/path/to/worktree/ --git-dir=/path/to/repo/ checkout -f master`. So, perhaps it's just a matter of calling `mv` right after. – NinjaFart May 18 '16 at 20:35

1 Answers1

3

Later in post-receive I am calling git --work-tree=/path/to/worktree/ --git-dir=/path/to/repo/ checkout -f master
So, perhaps it's just a matter of calling mv right after.

Exactly: right after, and in an actual worktree (/path/to/worktree/) instead of the current bare repo. Any action on files needs to be done in a checked out repo instead of a bare repo.

The other approach would be to push directly to a non-bare repo, but your approach is safer (first updating a bare repo, then checkout/update elsewhere).

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250