Team development is essential! Explaining git clone, fetch, pull
thank you for your hard work!
My name is Yamada from the System Development Department.
This time,
I will explain the differences between the frequently used git commands used in team development: git clone, git fetch, and git pull.
git clone
Command to clone a repository.
You can import project repositories created by others into your own environment.
```````````````````````````````````````````````` ````````````````$ git clone [repository to be cloned] [directory name (optional)] ________________________________________________________________
git fetch
Command to update remote tracking branches.
Bring the latest information from the remote repository to the local repository.
```````````````````````````````````````````````` ```````````````` $ git fetch [repository name (optional)] [branch name (optional)] ________________________________________________________________
However, since this only updates the remote tracking branch,
the updates will not be reflected in the current working branch.
When do you want to reflect your work?
If you want to reflect it in the current working branch, use merge.
```````````````````````````````````````````````` ````````````````$ git merge [branch name you want to reflect] ________________________________________________________________
git pull
After performing `git fetch` as explained above, perform `git merge origin/main`.
```````````````````````````````````````````````` ````````````````$ git pull [repository name (optional)] [branch name (optional)] ________________________________________________________________
How to use each command
Use this when there is nothing in your local environment, such as when starting a git clone
git fetch
when there is likely to be a conflict between the remote and local environments
, such as when importing a branch edited by another person, you want to confirm before merging.
It is often used for branches that are updated only by pull requests from other branches in a remote environment, such as
the git pull (Since there is basically no conflict with the local environment, there is no need to check the differences.)
summary
This time, we explained the differences between the frequently used git commands used in team development: git clone, git fetch, and git pull.
It is unlikely that you will do team development without using this command, so
if you learned about it for the first time today, we recommend that you understand it perfectly!
command name | Content |
---|---|
git clone | Command to clone an already existing repository |
git fetch | Command to update remote tracking branch |
git merge | Command to reflect the contents of other branches, including remotely tracked branches, into the current branch |
git pull | Command to update the remote tracking branch and reflect it in the working branch, etc. |
lastly
I have opened the system development service site "SEKARAKU Lab" to which I belong.
Beyond is a one-stop service for everything from server design and construction to operation, so if you have any trouble with server-side development, please feel free to contact us.
SEKARAKU Lab: https://sekarakulab.beyondjapan.com/