Git Skip Worktree on All Tracked Files inside Directory and its Subdirectories

前端 未结 1 956
一个人的身影
一个人的身影 2021-02-06 02:48

Let\'s say I have this worktree that has already been tracked by git.

.
├── parent
│   ├── child1
│   |    └── file1.txt
│   ├── child2
│   |    ├── file2.txt
│          


        
相关标签:
1条回答
  • 2021-02-06 03:06

    Similarly to assume-unchanged, you need to apply this command to all files within a folder:

    find . -maxdepth 1 -type d \( ! -name . \) -exec bash -c "cd '{}' && pwd && git ls-files -z ${pwd} | xargs -0 git update-index --skip-worktree" \;
    

    (there is no "recursive" option to git update-index)

    EDITED:

    Don't forget to cd into the directory that you want to skip first, then run the above commands.

    And, if you want to undo it, just do the opposites with this:

    find . -maxdepth 1 -type d \( ! -name . \) -exec bash -c "cd '{}' && pwd && git ls-files -z ${pwd} | xargs -0 git update-index --no-skip-worktree" \;
    
    0 讨论(0)
提交回复
热议问题