ASP.NET Core + Reactのプロジェクトをgitで管理するための設定
ASP.NET Core + Reactのプロジェクトをgitで管理するための設定をします。
ASP.NET Core + Reactのプロジェクトを作成するで作成したプロジェクトに対して修正します。
.gitattributesの追加
WindowsやLinuxなど複数の環境で作業をしている場合、改行コードが勝手に変換されてしまう場合があるため、.gitattributesを使用して、改行コードの扱いを明示的に指定します。
改行コードは、ASP.NET CoreのソースはCRLF、ReactのソースはLFで管理するようにしたいため、それぞれのプロジェクトのルートディレクトリに.gitattributesのファイルを作成します。
.gitattributes(ASP.NET)* text=auto.gitattributes(React)* text=auto eol=lfASP.NET Coreについては、プロジェクトを複数作成する場合が多いので、gitの設定は各プロジェクトごとに設定するのではなく、一つ上位のディレクトリに設定して、すべてのプロジェクトに対してまとめて設定します。
最終的には以下のような構成になります。(一部のファイルは省略しています)
- .devcontainer
- .devcontainer.json
- .vscode
- settings.json
- App.Web
- ClientApp
- src
- .editorconfig
- .gitattributes
- .gitignore
- package.json
- App.Web.csproj
- Program.cs
- ClientApp
- docker
- app
- Dockerfile
- app
- .editorconfig
- .gitattributes
- .gitignore
- docker-compose.yml