In this step, we will learn how to use Git and GitHub.
📖 Reference
- (JA)Gitを使ったバージョン管理
- (JA)Udemy Business - Git:はじめてのGitとGitHub
- (EN)Git basics
- (EN)Udemy Business - GitHub Ultimate: Master Git and GitHub - Beginner to Expert
- Fork mercari-build-training
- You will see be able to see
https://github.com/<your github id>/mercari-build-trainingif successful.
-
Install git in your environment and run the following command.
$ git version
-
Set your name and email address using git config. Check if your email address shows up.
$ git config --global user.name "<your name>" $ git config --global user.email "<your-email-address>" $ git config user.email <your-email-address>
- Follow the GitHub documentation to setup SSH-key.
- Clone
https://github.com/<your github id>/mercari-build-trainingonto your local using the following command. Follow the below image to get the ssh url.
$ cd <your working space> $ git clone git@github.com:<your github id>/mercari-build-training.git
Please definitely run the following command after cloning repository.
cd mercari-build-training
git config --local core.hooksPath .githooks/
This is required to use githooks in mercari-build-training repository.
- Make a new branch named
first-pull-requestand switch into this branch$ cd <your working space>/mercari-build-training $ git branch first-pull-request $ git switch first-pull-request
- Replace
@your_github_idon README.md with your GitHub ID. - commit the changes you made with the following commands.
$ git status # Check your change $ git add README.md # Add README.md file to the list of files to commit $ git commit -m "Update github id" # Brief description about the changes
- push changes to GitHub.
$ git push origin first-pull-request:first-pull-request
- Open
https://github.com/<your github id>/mercari-build-trainingand make a Pull Request (PR).- base repository:
<your github id>/mercari-build-training - base branch:
main - target branch:
first-pull-request
- base repository:
- Once you made a PR, ask a teammate for review.
- If at least one person
approves the PR,mergeinto the main branch - Open your teammates' PRs and check the files changed, and
approveif you think the changes look good.
📖 Reference
🔰 Points
Check if you understand the following concepts.
- branch
- commit
- add
- pull, push
- Pull Request
When the original repository is updated, you have to pull the changes into your forked repository as well.
- Update your forked repository
Please open https://github.com/<your github id>/mercari-build-training in your browser, please update your repository as follows:
- Update your local environment
git fetch origin
git merge origin/main
