0

在我的项目中,我想忽略一行代码,因为它包含一个对于 repo 的每个用户都不同的目录。

我为我的问题找到了一个有用的答案,但是我不知道如何将其应用于我自己的问题。

我需要忽略的行如下: MyMesh.loadMesh("D:/Software Projects/OpenGL/Raytracing-Project/dodgeColorTest.obj", true);

所以我想知道的是我必须在$ git config filter设置中插入什么,用于清洁和涂抹的情况。

4

1 回答 1

1

您的问题的标准解决方案是将字符串移动到配置文件中并将该文件添加到.gitignore. 此外,将文件的重命名副本连同有关如何使用它的说明一起放入存储库。

配置文件的格式和您使用它的方式取决于您使用的语言。


对于C,C++和类似的语言,它可以像.h包含以下内容的文件一样简单:

/**
 * This file contains various constants (paths, for example) that are specific
 * to the computer where this code is compiled.
 *
 * Make a copy of this file as 'config.h' and change it to match your system.
 */

#ifndef __CONFIG_H__
#define __CONFIG_H__


/* The path to the OBJ file used by blah-blah-blah feature */
#define OBJ_PATH "D:/Software Projects/OpenGL/Raytracing-Project/dodgeColorTest.obj"


#endif

为其命名config.h.dist(或使用更适合您的项目和编码风格的其他名称)并将其添加到存储库中。

将其复制为config.h并添加config.h.gitignore.

放入#include "config.h"从上面提取代码的文件中,并用定义的符号替换具体文件路径config.h

#include "config.h"

MyMesh.loadMesh(OBJ_PATH);

使用该技术从代码中提取在config.h您同事的系统上可能不同的所有值。不要忘记将它们config.h.dist也添加到其中,并附上关于它们的类型和它们可能具有的值的相关描述。

于 2015-06-04T14:40:17.777 回答