Will a git checkout delete files that shouldn't be there?

前端 未结 1 1601
隐瞒了意图╮
隐瞒了意图╮ 2021-02-13 19:06

If I set up a post-recieve hook in git like

#!/bin/sh
GIT_WORK_TREE=/var/www/www.example.org git checkout -f

Will that delete files that are o

1条回答
  •  花落未央
    2021-02-13 19:22

    It depends if the files will be deleted depending if they already existed in the repository prior to the checkout.

    If the files that are on the server (/var/www/www.example.org) are tracked in the repo on the server but the new checkout includes a change that removed them then they will be removed on the server side.

    If the files that are on the server are NOT tracked in the repo on the server then they will stay. Since Git doesn't know about them Git won't remove them.

    To tell if they are tracked on the server you can do git status . If it says:

    # Untracked files:
    #   (use "git add ..." to include in what will be committed)
    #
    #       
    

    Then you know that a checkout would not remove .

    Just take note if later exists in a new checkout than the next checkout which removes would remove it.

    0 讨论(0)
提交回复
热议问题