简体   繁体   English

如何在本地工作区中设置 git 以默认接受某些文件的所有传入更改?

[英]How to setup git in a local workspace to accept all incoming changes by default for some files?

I have a folder that is set to be compiled whenever I do some changes.我有一个文件夹,每当我做一些更改时都会编译它。 Sometimes, however, I do some changes that are not supposed to be compiled, such as testing something.然而,有时我会做一些不应该编译的更改,例如测试某些东西。

The compiled files contain the current date of compilation, so even if the two compiled files are the same the time would be different in both.编译文件包含当前编译日期,因此即使两个编译文件相同,两者的时间也会不同。 Now this is not a problem until I have to merge some changes.现在这不是问题,直到我必须合并一些更改。

How do I set up my configuration so that a specific folder (in my case compiled ) is always Accept Theirs by default without asking me to git pull -X theirs compiled every single time?如何设置我的配置,以便特定文件夹(在我的情况下为已compiled )始终默认接受他们的而不要求我每次都git pull -X theirs compiled

Or if you have any alternative method of doing the same thing differently?或者如果你有任何不同的方法来做同样的事情? The reason for this is because whenever I merge and the other person has compiled on his machine and pushed the compiled code, I will be receiving the compiled code of his which result in a merge conflict.这样做的原因是因为每当我合并并且其他人在他的机器上编译并推送编译代码时,我都会收到他的编译代码,这会导致合并冲突。

The compilation locally doesn't matter as it's just a bunch of compiled stuff for production, but for the online repo, or for someone who's cloning the repo just to try it out the compiled files should be present, therefore I cannot add the folder to .gitignore as that will prevent it from coming up entirely.本地编译无关紧要,因为它只是一堆用于生产的编译内容,但对于在线存储库,或者对于克隆存储库只是为了尝试它的人来说,编译文件应该存在,因此我无法将文件夹添加到.gitignore因为这将阻止它完全出现。

Edit:编辑:

I tried GitHub actions to do the compilation on the repo itself, which does work, but still gives me the same problem of having to merge when I receive the new pull, or the compiled files are stored in releases/artifact repo so I no longer have them locally.我尝试了 GitHub 操作来对 repo 本身进行编译,这确实有效,但仍然给我同样的问题,即当我收到新的 pull 时必须合并,或者编译的文件存储在发布/工件 repo 中所以我不再让他们在当地。

but for the online repo, or for someone who's cloning the repo just to try it out the compiled files should be present, therefore I cannot add the folder to.gitignore as that will prevent it from coming up entirely但是对于在线回购,或者对于克隆回购只是为了尝试它的人来说,编译文件应该存在,因此我不能将文件夹添加到.gitignore,因为这会阻止它完全出现

That's exactly how it's supposed to work.这正是它应该如何工作的。 You don't commit compiled code for that reason.出于这个原因,您不会提交已编译的代码。 Another person checking out your repo will have to compile it locally, and you will have to compile it somewhere else before you deploy it to a server.检查您的存储库的另一个人必须在本地编译它,并且您必须在将其部署到服务器之前在其他地方编译它。

Git is for source code, not for artifacts. Git 用于源代码,而不用于工件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM