Skip to main content

Git workflow

This is AGL's process of working with Git during training and after training.

Check git information

caution

In this step, you only need to do it once after installing git.

When starting a new project or participating in an existing project, check that you have set up local username and email information.

$ git config –global –list

In case the information is wrong, reset it with the following command:

$ git config --global user.name "AGL..."
$ git config --global user.email "staff@allgrow-labo.jp"
  • user.name: corresponds to your Slack name
  • user.email: email that the company gives you
info

--global is used to apply to all projects. If you do not use --global then the settings will only apply to the current project.

Clone repository

To clone a repository locally, use the command:

$ git clone <remote_repository_URL>

When cloning, git will automatically create a folder with the same name as the repository, please pay attention.

Create a branch

caution

Always check which branch you are in before starting work, because if you are careless you may get confused.

During the training process, please comply with the following code storage standards: Git's default will be the master (main) branch, you do not perform any operations on this branch.
Create a new branch from master before starting any work.

  • Coding tasks (HTML/CSS/JS): feature/coding-...
  • Feedback repair tasks: issue/fix-bug-...
  • Tasks about wordpress (theme): feature/wordpress-...
  • Documentation tasks: feature/docs-...

How to both create a branch and switch to a new branch:

$ git checkout -b <new_branch>

Update changes

After completing your tasks for the day, you need to commit them before leaving.

   $ git add .
$ git commit -m "commit message"

The commit content must briefly state what you have done, so that when others read it, they will also know what you have done.

👉 Refer to how to write commit properly: Commit Lint

After completing the commit, the next step is to push the data to the Git server.

   $ git push

And that's it, you've basically completed a process when working with Git. But it's not over yet.

We will continue our work the next day, think about the situation where another engineer is also working on the same project while we finish our work, it will be troublesome if we are out of sync code together. So use git pull before starting new work on the project, so your local can see the latest data.

   $ git pull
caution

Get into the habit of pulling source code before you want to push something to git.

Create a Pull Request and ask for Code Review

Go to git server, create [Pull Request](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/creating- a-pull-request) and ask for confirmation (review) from the person in charge.

Merge Pull Request into master

Mentor or manager, after checking the source code, will ask you to [merge Pull Request](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/incorporating-changes-from- a-pull-request/merging-a-pull-request) into the master branch.

Then remember to synchronize the code in the master branch in the local and origin environments:

  $ git checkout master
$ git pull origin master

Note

Please note that if asynchrony between local and remote occurs, you will encounter a code conflict.
Therefore, you must check the code before pushing the code to Git.