Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you hide .git project directories?

Tags:

git

regex

nginx

Now that I have nginx setup I need to be able to hide my .git directories. What kind of rewrite would I need to stop prying eyes? And where in the server {} or http {} block would it go?

like image 502
Xeoncross Avatar asked Jun 08 '10 16:06

Xeoncross


People also ask

How do I exclude a .git folder?

Repository exclude - For local files that do not need to be shared, you just add the file pattern or directory to the file . git/info/exclude .

Is .git folder hidden?

The . git folder is hidden to prevent accidental deletion or modification of the folder. The version history of the code base will be lost if this folder is deleted.

Is .git folder tracked?

No, there isn't. But you can store in git a text files with the 2 or 3 commands you use to reconfigure each repository. You can make it a .

What happens if I delete .git folder?

Deleting the . git folder does not delete the other files in that folder which is part of the git repository. However, the folder will no longer be under versioning control.


1 Answers

http {   server {     location ~ /\.git {       deny all;     }   } } 

This location directive will deny access to any .git directory in any subdirectory.

Note: This location block must be before your main location block, so that it can be evaluated first.

like image 119
rzab Avatar answered Sep 19 '22 01:09

rzab