Git

What Happens When I Do git pull origin master in the Develop Branch?

Git developers work with multiple branches on a local repository to implement the project’s source code. After that, they can push the added changes to the remote repository to update it with modifications. Moreover, the latest code can be pulled from the GitHub repository on the working branch where the HEAD is pointing.

This write-up will discuss what happens when “git pull” executes with the “origin master” in the develop branch.

What Happens When “git pull origin master” in the Develop Branch?

When a developer wants to download the new code version from remote repository branches with the remote and branch name, the “git pull” command can be utilized. For instance, we will download the latest version of the development project source code from the “master” branch to the current HEAD pointing branch “dev” develop local branch.

To do so, follow the below-listed instructions:

  • Go to a particular Git local repository.
  • Check existing branches.
  • View the remote URLs list.
  • Execute the “$ git pull origin master” command.

Now, let’s implement the above-described scenario!

Step 1: Move to Git Repository
First, specify the path of desired Git repository with the “cd” command and move to it:

$ cd "C:\Users\nazma\Git\Test_14"

Step 2: View List of All Branches
Now, execute the “git branch” command with the “-a” option to view all the remote and local branches:

$ git branch -a

Here, all branches will be displayed; select the required one:

Step 3: Check Remote URLs
Then, check the all existing remote URLs by running the “git remote” command:

$ git remote -v

It can be seen that our local and remote repositories are connected through the remote URL:

Step 4: Git Pull Origin Master
Lastly, run the “git pull” command along with the remote and desired branch name:

$ git pull origin master

It can be seen that “git pull” will download the latest version of code from the specified branch named “master” on the remote named “origin” and integrates them into the current working branch where HEAD pointing called “dev”:

We have explained what happens when git pulls origin master in the develop “dev” branch.

Conclusion

The “$ git pull” command is used to download the latest version of remote repository branches along with the remote and branch name. To download the code from the “master” branch name with the remote name “origin”, first move to the Git repository, check the list of branches and remote URLs. Lastly, run the “$ git pull <remote-name> <branch-name>” command. This write-up illustrated what happens when git pulls origin master in the develop “dev” branch.

About the author

Maria Naz

I hold a master's degree in computer science. I am passionate about my work, exploring new technologies, learning programming languages, and I love to share my knowledge with the world.