location / { # First attempt to serve request as file, then # as directory, then fall back to displaying a 404. try_files$uri$uri/ =404; }
location~ (/.*) { client_max_body_size0; # Git pushes can be massive, just to make sure nginx doesn't suddenly cut the connection add this. auth_basic"Git Login"; # Whatever text will do. auth_basic_user_file"/home/git/htpasswd"; include /www/server/nginx/conf/fastcgi_params; # Include the default fastcgi configs,由具体nginx配置路径决定 fastcgi_param SCRIPT_FILENAME /usr/lib/git-core/git-http-backend; # Tells fastcgi to pass the request to the git http backend executable fastcgi_param GIT_HTTP_EXPORT_ALL ""; fastcgi_param GIT_PROJECT_ROOT /home/git; # /var/www/git is the location of all of your git repositories. fastcgi_param REMOTE_USER $remote_user; fastcgi_param PATH_INFO $1; # Takes the capture group from our location directive and gives git that. fastcgi_pass unix:/var/run/fcgiwrap.socket; # Pass the request to fastcgi }
# 创建测试文件 mkdir test1 test2 test3 echo "This is my first repository" > test1/repo1 echo "This is my second repository" > test2/repo2 echo "This is my third repository" > test3/repo3
# 添加并提交 git add . git commit -a -m "Add files and directoires"