如何防止 git 将更改推送到某些文件
我使用 git svn 克隆了一个 subversion 存储库。源代码有一些配置文件,我必须编辑它们以适合我的系统。我想将对这些文件的更改存储在本地存储库中(以便在分支之间轻松切换,而不必担心本地修改的文件),但我想阻止这些更改被推送到远程存储库。
有人可以帮助我吗?
提前致谢。
I've cloned a subversion repository using git svn. The source has some config files that i have to edit to fit my system. I would like to store my changes to those files in my local repo (to easily switch between branches without worrying about locally modified files) but i would like to prevent those changes to be pushed to the remote repository.
Can anybody help me?
Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
大约一年前,我写了 git-overlook,我现在意识到它是一个基于 hunk 的 git -忽略。它是 alpha 软件,并没有我想要的所有功能,但也许正是您正在寻找的功能。
About a year ago I wrote git-overlook, which I now realize is a hunk-based git-ignore. It's alpha-software and does not have all the features I want, but perhaps what you're looking for.
您不能将这些文件放入
.gitignore
中并按原样使用存储库的其余部分吗?我认为应该有效。或者您希望文件在本地进行版本控制但不推送?我不确定这是否可能,因为推送的是更改而不是文件。如果存储库中已有 .gitignore,您可以更改本地 git 配置以使用另一个排除文件,在其中排除您想要的文件(git help gitignore)以获取详细信息。那行得通吗?
Can't you just put those files in
.gitignore
and use the rest of the repo as is? I think it should work. Or do you want the files to be version controlled locally but just not pushed? I'm not sure if that's possible since it's changes that get pushed rather than files.If you already have a .gitignore in the repo, you can alter your local git config to use another exclude file in which you exclude the files you want to (git help gitignore) for details. Would that work?