What is a practical workflow for keeping local changes uncommitted in git?

前端 未结 1 2042
难免孤独
难免孤独 2021-02-20 11:50

What I want to do is already described in that question. But I want to solve that problem in a practical and more generic way. So the use-case is the following:

  • I
相关标签:
1条回答
  • 2021-02-20 12:10

    You could try doing the following before your git commit:

    git update-index --assume-unchanged web.config crateDb.sql
    

    From git help:

    --assume-unchanged

    --no-assume-unchanged

    When these flags are specified, the object names recorded for the paths are not updated. Instead, these options set and unset the "assume unchanged" bit for the paths. When the "assume unchanged" bit is on, git stops checking the working tree files for possible modifications, so you need to manually unset the bit to tell git when you change the working tree file. This is sometimes helpful when working with a big project on a filesystem that has very slow lstat(2) system call (e.g. cifs).

    This option can be also used as a coarse file-level mechanism to ignore uncommitted changes in tracked files (akin to what .gitignore does for untracked files). Git will fail (gracefully) in case it needs to modify this file in the index e.g. when merging in a commit; thus, in case the assumed-untracked file is changed upstream, you will need to handle the situation manually.

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