git pull忽略指定文件_Git:忽略Commit和Pull中的特定文件

I am "ignoring" our ConnectionString.config using update-index --assume-unchanged, as I change it often during development and is generated automatically by our build server anyway; however, when performing a Pull/Rebase the operation fails because it would overwrite it locally, forcing me to stash it and then restore it.

Is there a way to ignore a file both on commit and on pull? I just want Git to leave it be.

解决方案

If you want this to only happen on your local system, the local .git/info/exclude file should solve the problem.

To requote the answer from the above stack post:

Patterns which are specific to a particular repository but which do

not need to be shared with other related repositories (e.g., auxiliary

files that live inside the repository but are specific to one user's

workflow) should go into the $GIT_DIR/info/exclude file.

The .git/info/exclude file has the same format as any .gitignore file. Another option is to set core.excludesFile to the name of a file containing global patterns.

Note, if you already have unstaged changes you must run the following after editing your ignore-patterns:

git update-index --assume-unchanged [...]

Note on $GIT_DIR: This is a notation used all over the git manual simply to indicate the path to the git repository. If the environment variable is set, then it will override the location of whichever repo you're in, which probably isn't what you want.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值