Git忽略对部分跟踪文件的本地更改 [英] Git ignore local changes to portions of tracked files

查看:592
本文介绍了Git忽略对部分跟踪文件的本地更改的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

具体来说,我维护一个我的dotfiles的git仓库。我最近开始研究一台新机器,并克隆我的存储库。



现在,我希望对仅针对该系统的dotfiles进行一些更改。这些更改我希望在我的存储库中忽略。



我做的其他更改应继续进行跟踪和提交。



例如,在我的.gitconfig中,我有一个设置:

  default = simple 

现在,在我的新机器上, git版本正在使用它非常古老。它仍然不支持用于推送的设置 simple 。所以,我想改变这一点,但只能在本地。



但是,如果我对.gitconfig做任何其他更改,我想跟踪那些。无论如何,我可以做到这一点?

编辑:

我知道 git update-index --assume-unchanged 。问题在于git将不再跟踪我的文件,直到我将其反转。然后,它会跟踪所有更改。

我希望忽略某些更改并跟踪其余部分。

解决方案

我不相信有一个特定的命令可以解决文件的某些更改。但是,没有理由不能创建一个本地分支,从中取出遥控器中的更改,但不要发回任何更改。


Specifically, I maintain a git repository of my dotfiles. I recently started working on a new machine and cloned my repository on the same.

Now, I wish to make some changes to my dotfiles which are specific to this system only. These changes I wish to ignore in my repository.

Other changes that I make, should continue to be tracked and committed.

For example, in my .gitconfig, I have a setting as:

[push]
   default = simple

Now, on my new machine, the version of git being used it very old. It still not not support the setting simple for push. So, I'd like to change this, but only locally.

However, if I make any other changes to my .gitconfig, I'd like to keep track of those. Anyway I can achieve this?

EDIT:
I know of git update-index --assume-unchanged. The problem with it is that git will no longer track my file at all, until I reverse it. And then, it will track all changes.
I wish to ignore certain changes and track the rest.

解决方案

I don't believe there's a specific command that will 'untrack' certain changes to a file. However, there's no reason that you couldn't create a local branch into which you pull changes from your remotes, but never send any changes back.

这篇关于Git忽略对部分跟踪文件的本地更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆