Why are you using ‘git pull’ ?

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 th…


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:

  1. Switch to the other branch
  2. git pull the latest code for that branch
  3. Switch back to the working branch
  4. 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


Print Share Comment Cite Upload Translate Updates
APA

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/

MLA
" » Why are you using ‘git pull’ ?." Nick Groos | Sciencx - Monday May 10, 2021, https://www.scien.cx/2021/05/10/why-are-you-using-git-pull/
HARVARD
Nick Groos | Sciencx Monday May 10, 2021 » Why are you using ‘git pull’ ?., viewed ,<https://www.scien.cx/2021/05/10/why-are-you-using-git-pull/>
VANCOUVER
Nick Groos | Sciencx - » Why are you using ‘git pull’ ?. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2021/05/10/why-are-you-using-git-pull/
CHICAGO
" » Why are you using ‘git pull’ ?." Nick Groos | Sciencx - Accessed . https://www.scien.cx/2021/05/10/why-are-you-using-git-pull/
IEEE
" » Why are you using ‘git pull’ ?." Nick Groos | Sciencx [Online]. Available: https://www.scien.cx/2021/05/10/why-are-you-using-git-pull/. [Accessed: ]
rf:citation
» Why are you using ‘git pull’ ? | Nick Groos | Sciencx | 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.

You must be logged in to translate posts. Please log in or register.