This content originally appeared on DEV Community and was authored by Nick Groos
I have noticed that for whatever reason, new developers love to use git pull
for merging code. To get latest from another branch, they will do something like this:
- Switch to the other branch
-
git pull
the latest code for that branch - Switch back to the working branch
- Merge the freshly pulled code into the working branch
So, git pull
can get the job done. And developers will go months or years unaware of the much more nimble git fetch
.
The problem is that the steps above require us to switch branches, a slow git operation, two times. We can achieve the same outcome without switching branches by using git fetch
:
git fetch origin develop
git merge origin/develop
And we have the latest from /develop into our current working branch.
The seemingly small efficiency gained from a workflow that uses git fetch
instead of git pull
will result in hours of saved time over the course of a project.
For more context I recommend this discussion about 'git fetch' vs 'git-pull'
This content originally appeared on DEV Community and was authored by Nick Groos
Nick Groos | Sciencx (2021-05-10T16:54:11+00:00) Why are you using ‘git pull’ ?. Retrieved from https://www.scien.cx/2021/05/10/why-are-you-using-git-pull/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.