Can git ignore a specific line?

2019-01-02 19:42发布

I'm using git to sync to phonegap while testing on the phone's native browser. As such I have the following line:

var isPhoneGap = false;

Obviously I change this when building, but is there any way I can set up git to ignore this one line or do I have to go and put it in its own file and ignore it that way?

I'm using Gitx and the terminal on OSX 10.6.

标签: git gitx
8条回答
皆成旧梦
2楼-- · 2019-01-02 20:45

Gitx should let you commit or ignore individual lines (you may know that already), but you'd have to do that every time you commit. I think it would be better to have a config file per deployment target (you can version those), and some runtime parameter for however you are starting the server (like ./myserver --config=whatever.js).

查看更多
旧时光的记忆
3楼-- · 2019-01-02 20:46

Nope. You can only ignore individual files (and more) since the lines in .gitignore matches file names and not file content. You have already mentioned the solution to this, i.e. ignore a single file that contains that content you want to ignore.

查看更多
登录 后发表回答