How to tell git to ignore all further edit to a single file without removing it from the repo

后端 未结 1 434
伪装坚强ぢ
伪装坚强ぢ 2020-12-22 21:27

I have forked a project on github and started messing around with it on my own machine, I want to commit the changes I have made back to my fork on github but without commit

相关标签:
1条回答
  • 2020-12-22 21:58

    Use this:

    git update-index --skip-worktree path/file.cfg
    

    And to restore:

    git update-index --no-skip-worktree path/file.cfg
    

    Lastly, if you want to list files that are marked with skip-worktree:

    git ls-files -v | grep ^S | awk '{print $2}'
    

    To simplify, you can make an alias for that in your $HOME/.gitconfig:

    [alias]
        ls-ignored-changes = !git ls-files -v | grep ^S | awk '{print $2}'
    

    Then you can type just git ls-ignored-changes. It even works with auto-completion if you have the git-completion in place (for bash, tcsh, zsh).

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