Essential for team development! Explaining git clone, fetch, and pull

Thank you for your hard work!
This is Yamada from the System Development Department.
we will explain the differences between git clone, git fetch, and git pull , which are frequently used git commands in team development
git clone
A command to clone a repository.
You can drop a repository of a project created by someone else into your own environment.
`````````````````````````````````````````````````````````````````````````````````````````````````````$ git clone [repository to clone] [directory name (optional)] ________________________________________________________________
git fetch
A command to update a remote-tracking branch,
bringing the latest information from the remote repository into the local repository.
``````````````````````````````````````````````````````````````````````````````````````````````$ git fetch [repository name (optional)] [branch name (optional)] ________________________________________________________________
However, since this only updates the remote-tracking branch,
the updates are not reflected in the current working branch.

What if you want to reflect your work?
If you want to update your current working branch, use merge
`````````````````````````````````````````````````````````````````````````````````````` $ git merge [branch name you want to merge] ________________________________________________________________

git pull
After running `git fetch` as explained above, run `git merge origin/main`
`````````````````````````````````````````````````````````````````````````````````````````````$ git pull [repository name (optional)] [branch name (optional)] ________________________________________________________________

How to use each command
Use this when you have nothing in your local environment, such as when starting a git clone
git fetch
when there is a possibility of conflicts occurring between the remote and local environments,
such as when importing a branch edited by someone else, you want to check before merging.
This is often used for branches that are updated only by pull requests from other branches in a remote environment, such as
the git pull (This is because conflicts with the local environment are basically impossible, so there is no need to check the differences.)
summary
This time, we explained the differences between the frequently used git commands git clone, git fetch, and git pull in team development.
It's almost impossible to do team development without using these commands, so
if you learned about them for the first time today, we recommend that you fully understand them!
| Command name | Content |
|---|---|
| git clone | Command to clone an existing repository |
| git fetch | Command to update a remote-tracking branch |
| git merge | Commands to merge other branches, including remote-tracking branches, into the current branch |
| git pull | Command to update a remote-tracking branch to reflect the working branch, etc |
lastly
I have launched a system development service site called "SEKARAKU Lab," which I work for.
Beyond can handle everything from server design and construction to operation, so if you have any problems with server-side development, please feel free to contact us.
SEKARAKU Lab: https://sekarakulab.beyondjapan.com/
1