search

Home  >  Q&A  >  body text

如何设置使git status不显示某些文件(已经在git仓库中)的变更

假设git仓库中有文件A B C D,我本地修改了一些,然后使用git status发现A B C都被修改,但A文件其实不能commit(比如去掉了一些LOG,使我调试时能少关注一些东西,但其他人还需要这些LOG)
这样每次git status都会显示出A需要commit(实际有不止一个类似A的文件),然后我需要从这些文件中查找出哪些是确实需要commit的,然后使用git commit B C命令.

我想知道的是:
1.如何不显示A文件的变动,使用git commit -a把其它文件全部commit而不再输入B C的文件名
2.如果A被其他人修改并push,当用我git pull时能取得最新的A

伊谢尔伦伊谢尔伦2843 days ago883

reply all(3)I'll reply

  • 天蓬老师

    天蓬老师2017-04-24 09:16:04

    I just saw this problem some time ago. You can use git update-index --skip-worktree [file] to achieve your needs. There is also a usage of --assume-unchanged. The difference between them can be found in the link.

    Related discussion link:
    Link 1

    Link 2

    reply
    0
  • 高洛峰

    高洛峰2017-04-24 09:16:04

    git update-index --assume-unchanged /path/to/file

    reply
    0
  • 天蓬老师

    天蓬老师2017-04-24 09:16:04

    git rm --cached file_name

    reply
    0
  • Cancelreply