2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

環境毎でGit除外したいファイルは.git/info/excludeに追記する

Last updated at Posted at 2021-09-10

環境毎でGit管理したくないファイルがある

管理したくない環境:

サーバ側

$ ls -al
.
..
.git
.gitignore
README.md
docker
└default.conf  ←管理したくないファイル
docker-compose.yml
src

方法:

各リポジトリの.git/info/excludeに追記

# git ls-files --others --exclude-from=.git/info/exclude
# Lines that start with '#' are comments.
# For a project mostly in C, the following would be a good set of
# exclude patterns (uncomment them if you want to use them):
# *.[oa]
# *~
docker/default.conf ←追記

反映させる:

$ git update-index --assume-unchanged docker/default.conf

きっかけ:

サーバ側だけdefault.confを変えたかったから。

詳細:

ローカル環境のdefault.confは80番ポートのままで、サーバは常に443ポートにリダイレクトさせる為。

サーバのdefault.confはこれ

server {
    server_name  example.jp;
    listen 80;
    
    # 全てのリクエストをSSLサイトにリダイレクト
    location / {
        return 301 https://$host$request_uri;
    }
}
server {
    server_name  example.jp;
    listen       443 ssl;

    ssl_certificate      /etc/letsencrypt/live/example.jp/fullchain.pem;
    ssl_certificate_key  /etc/letsencrypt/live/example.jp/privkey.pem;

    root  /var/www/html/public;

    access_log /var/log/nginx/access.log;
    error_log  /var/log/nginx/error.log;
}

ローカル環境のdefault.confはこれ

server {
    listen       80;
    server_name  localhost;

    root  /var/www/html/public;

    access_log /var/log/nginx/access.log;
    error_log  /var/log/nginx/error.log;
}

結果

サーバでdefault.confを変更してもgit pushしなくて良くなった!

2
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?