5
2

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 1 year has passed since last update.

最速でコードを書き始める為のテンプレートリポジトリの賢い使い方

5
Last updated at Posted at 2024-09-10

これは何?

新たになにかを作ろうと思い立ったものの,環境構築に時間がかかってしまうことはないでしょうか。

本記事では,GitHubでのリポジトリの共通部分を使い回せるtemplate repositoryの使い方を解説します。
皆様がtemplate repozitoryを使って爆速で開発をスタートしましょう。


template repositoryとは?

公式ドキュメント

template repositoryを使うと毎回使うファイル等をテンプレートとしてGitHubで管理することができます。

例えば,template repozitoryに登録しておくことでコードをすぐに書き始めることが可能になります。

最近issueやpull requestのテンプレート化やCODEOWNERSファイルを使っている開発現場も増えてきていると思うのでtemplate化には大変意義があると思われます。


template repositoryの使い方

公式ドキュメントにも記載があるのですが,若干わかりにくかったので図を追加で貼りながら説明します。

  1. GitHubのリポジトリを作成する。作成したrepositoryがtemplate repositoryになります。

  2. template repositoryに入れたいファイルやディレクトリをGitHubにpushする

    git clone <作成したrepository名>
    # いろいろ追加する
    git add .
    git commit -m "コミットメッセージ"
    git push -u origin main
    
  3. GitHubからrepositoryの設定を変更してtemplate repositoryとして使えるようにチェックをいれます。
    image.png

  4. 新たにrepositoryを作成する際にtemplate repositoryを選択することでtemplate repositoryの内容がコピーされたリポジトリを作成することができます。
    image.png


自分のtemplate repositoryの紹介

参考までに自分のtemplate repositoryを置いておきます。
よく使う言語があればtemplate repositoryは複数作成できるのでよく使う言語があれば言語に特価したものを作ると良いと思います。


さらなる効率化を求めて

template repositoryは以前に記事を書いたDev Container等とも相性が良いと思います。Dev Containerを使ったことがない方はぜひ使ってみるとおもしろいと思います(上記のpython用のtemplate repositoryはDev Containersを使っています)。

次回はdotfilesを使ってさらに開発環境をエンハンスする方法を紹介する予定。

5
2
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
5
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?