Skip to content

Latest commit

 

History

History
124 lines (94 loc) · 4.89 KB

File metadata and controls

124 lines (94 loc) · 4.89 KB

STEP1: Git

このステップではGitとGitHubの使い方を学びます。

📖 Reference

mercari-build-training リポジトリをフォークする

  • mercari-build-training をあなたのGitHubにForkします。
  • Forkに成功すると https://github.com/<your github id>/mercari-build-training というようなリポジトリができます。

Gitをインストールする

  1. Gitをご自身のPCにインストールしてください。以下のコマンドが動けばOKです。

    $ git version
    • Macを使っている場合: brew をインストールしてから brew install gitを実行
    • For Windows user: Download installer
  2. git configに自分の名前とemailアドレスを設定します。以下のコマンドを実行して最後にあなたのemailアドレスが表示されればOKです。

    $ git config --global user.name "<your name>"
    $ git config --global user.email "<your-email-address>"
    $ git config user.email
    <your-email-address>

Gitの基本コマンドを使う

  1. SSH-keyのセットアップ GitHubの公式ドキュメントに従ってSSH-keyをセットアップします。
  1. https://github.com/<your github id>/mercari-build-trainingclone します。 cloneすると、github上のリポジトリを自分のローカルにDownloadできます。以下の画像に従ってsshのurlを取得できます。 clone-ssh.png
    $ cd <your working space>
    $ git clone git@github.com:<your github id>/mercari-build-training.git

‼️ 注意

cloneができたら必ず以下のコマンドを実行してください。

$ cd mercari-build-training
$ git config --local core.hooksPath .githooks/ 

これは mercari-build-training が githooks という機能を使うために必要なものです。

  1. first-pull-requestというブランチを作り、そのブランチにswitchします
    $ cd <your working space>/mercari-build-training
    $ git branch first-pull-request
    $ git switch first-pull-request
  2. README.md の中にある@your_github_id の部分をあなたのgithub idに書き換えてください
  3. 書き換えた内容を commitします
    $ git status # Check your change
    $ git add README.md # README.mdの変更をcommit対象にする
    $ git commit -m "Update github id" # どんな変更を加えたのかを伝えるコメント
  4. 変更内容をgithubにpushします
    $ git push origin first-pull-request:first-pull-request
  5. https://github.com/<your github id>/mercari-build-trainingを開き、Pull Request(PR)を作ります。
    • base repository: <your github id>/mercari-build-training
    • base branch: main
    • target branch: first-pull-request

PRのレビューをする、PRのレビューをもらう

  • PRができたら、チームメイトにそのPRのURLを見てもらいます
  • 1人以上にapproveをもらえたらそのPRをmainブランチにmergeします
  • また、チームメイトのPRを開いて 変更内容を確認し、approve しましょう。

📖 Reference

🔰 Point

以下のキーワードについて理解できているか確認しましょう。

  • branch
  • commit
  • add
  • pull, push
  • Pull Request

最新の変更をpullする

fork元のリポジトリが更新された場合、その変更をforkした自分のリポジトリにも取り込む必要があります。

  1. forkしたリポジトリの状態を更新する

https://github.com/<your github id>/mercari-build-training をブラウザで開き、以下の通りforkしたリポジトリを更新してください。

fork-update1.png

fork-update2.png

  1. ローカルの状態を更新する
git fetch origin
git merge origin/main

Next

STEP2: 環境構築