Where does the Git pull point?

Asked

Viewed 1,789 times

9

I was reading the Git documentation about pull and I got confused:

So let’s create a hypothetical sequence:

  1. I cloned the repository
  2. I made a git branch which shows only the master.
  3. The command git branch -a shows my local branch (which is the master) and the other remote.
  4. I want to have the local branch develop. So I do git checkout -b develop origin/develop. Here is my question. When we do git checkout -b develop origin/develop are we pulling the remote develop arm or are we enabling locally a develop arm that was pulled at the time of the clone? Watching this part of the git pull documentation, It seems to me that it is the second scenario, because this is the justification of the git pull before making a pull da origin.

    Update the remote-tracking branches for the Repository you cloned from, then merge one of them into your Current branch:

    $ git pull
    $ git pull origin
    

I mean, it’s like the git pull origin, will pull from a local arm that is origin/develop but is not the develop that is in the central repository.

So that’s why we have to make one git pull to update all local images with remote content and then pull origin develop to update my develop local with origin/develop which is local tbm.

It confuses me because from within my branch develop git branch -vv show me:

develop bbfdft67 [origin/develop] ZF45: Modifications in the Tables and Chart in Faqs - Take 3,

So if my develop points to [origin/develop] I wouldn’t need to do git pull (as the documentation suggests) before making git pull origin, unless I wanted to update all local branches ("hidden"). And if that were the case, if git pull updated everything, I wouldn’t have to git pull origin from inside my develop.

So actually, where is it pulling (or updating data) when I do git pull?

  • 1

    The git pull makes a git fetch followed by a git merge. When you specify which remote, then it does not take from the default to that branch, but from the equivalent branch of the past remote.

2 answers

1

perform a git remote -v that it will show the association where the data comes from.

origin is a nickname that the git gives to a remote repository when it is cloned.

1

When we do git checkout -b develop origin/develop we’re pulling the remote develop arm or are enabling locally a develop arm that was pulled at the time of the clone?

When you checkout -b is creating a branch locally, the workflow secret is pushed from that local branch, which should be done with:

git push --set-upstream origin develop

I give you a full example of local branch creation https://analisedesistemas.wordpress.com/2018/06/27/git-branch-a-partir-de-outro-branch/

Browser other questions tagged

You are not signed in. Login or sign up in order to post.