DEV Community

Discussion on: Why are you using 'git pull' ?

Collapse
 
jessekphillips profile image
Jesse Phillips • Edited

I don't, and I don't recommend it. However git pull seems to match other version control systems more closely.

This causes a familiarity where your objective is to bring remote changes into your working tree. But git has local branches, so you first need to update your local branch and then merge that into your other branch.

As you point out, this line of thinking is actually less efficient than updating your local database followed by a merge.

But that brings me to the other confusion, when do you use a space vs a slash. Clearly you use a space when naming a remote, but that isn't clear.

$ git merge origin develop

I want to merge the develop branch on origin. This seems logical, but the command does not operate on a remote, if I switch the command to pull it works as desired.

Introducing the idea that the entire remote repository is locally available is yet another topic to cover.

There are really only two operations that you can do with the remote repository, push your local database and pull their remote database. All other operations occur against the local database.

But the pull command creates confusion as I should have said fetch instead oy pull even though without all the git lingo you'd expect the same thing.

Don't even get me started on why github has you create "pull requests" when you are wanting them to merge in your changes.

Collapse
 
groos profile image
Nick Groos

Nice overview. Yes, the 'git pull' workflow is something I see very often, without a good reason to invest the extra time for the pull.

Collapse
 
jessekphillips profile image
Jesse Phillips • Edited

Your workflow example also isn't the most optimal one could

git pull origin <branch>

I understand one wouldn't do this as it does not update you local copy of the branch. My view on that is of course different.

Thread Thread
 
thefluxapex profile image
Ian Pride

That's why I alias git pull origin master to gpom.

Thread Thread
 
jessekphillips profile image
Jesse Phillips

Yeah that is useless for me as I

git fetch origin
git rebase origin/master

Thread Thread
 
thefluxapex profile image
Ian Pride

Whatever works for you.

Thread Thread
 
jessekphillips profile image
Jesse Phillips

git pull --rebase origin master

Would actually do what I do. So many options.