Is there a way to tell git to ignore specific lines of a file?

I'm trying to put my .bashrc.gitconfig and other useful configs in github (because there are some valuable pieces of code that I want to share), but the fact is that I don’t want to share some “valuable information” about me, ”

is there any way around git to ignore specific patern or file line (e.g. in .gitignore?)

note: I understand how to make my bashrc public (I will keep bashrc in public things and navigate privately in bashprofile, which I don't share), but I'm kinda interested in how to share my gitconfig (there are some pretty good aliases )

THX

+4
source share
3 answers

I think it is possible to do something similar with the gitattributes and smudge and clean filters, but that would be dirty and probably pretty fragile. My method is simply to put things that I don’t want to publish in a file without common ~/.bashrc.local and the source file, which is inside a common .bashrc , for example

 if [ -r ~/.bashrc.local ]; then . ~/.bashrc.local fi 

It also allows me to maintain a system / machine dependent configuration without spinning my global .bashrc .

+8
source

therefore, to properly close this question:

answers, the answers to which are given here and in the comments for my problem (split.bashrc), but for the original question:

is there any way to tell git to ignore specific lines of the file?

no easy way

+2
source

To answer your question specifically (which is different from the specific problem you wanted to solve), check:

How to tell git to ignore individual lines, i.e. gitignore for specific lines of code .

0
source

All Articles