+1 vote
1 view
in Devops and Agile by (28.1k points)

I understand that a .gitignore file cloaks specified files from Git's version control. I have a project (LaTeX) that generates lots of extra files (.auth, .dvi, .pdf, logs, etc) as it runs, but I don't want those to be tracked.

I'm aware that I could (maybe should) make it so all those files are put in a separate subfolder in the project since I could then just ignore the folder.

However, is there any feasible way to keep the output files in the root of the project tree and use .gitignore to ignore everything except the files I'm tracking with Git? Something like

# Ignore everything

*

# But not these files...

script.pl

template.latex

# etc...

1 Answer

0 votes
by (48k points)
edited by

Yes, there is a feasible way to keep the output files in the root of the project tree and use .gitignore to ignore everything except the files you can track in git with

# Ignore everything

*

# But not these files...

!.gitignore

!script.pl

!template.latex

# etc...

# ...even if they are in subdirectories

!*/

# if the files to be tracked are in subdirectories

!*/a/b/file1.txt

!*/a/b/c/*

An optional prefix ‘!’ which negates the pattern; any matching file excluded by a previous pattern will become included again.if a negated pattern matches then it will override lower precedence pattern.

For more information please go through the following tutorial to get more info about git:

Related questions

+4 votes
1 answer
0 votes
1 answer
asked Jul 19, 2019 in Devops and Agile by chandra (28.1k points)
Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...