Git

How to Git Pull Remote Branch Without Merge

When developers want to push local machine data to the centralized server, GitHub, first, they are required to update the local repository with the updated version of the remote repository. For this purpose, they can execute the “git pull” command. This command will download the latest changes into their current working branch and combine them. Additionally, they can also perform this operation without merging both repositories’ data. The “–rebase” option can be used to do so.

This study will provide the process of performing the Git pull remote branch without merging it.

How to Git Pull Remote Branch Without Merge?

In order to perform Git pull operation on the local repository without merging the remote branch with a local branch, perform the below-listed instructions:

  • Go to the Git local repository.
  • View the list of existing remote URLs.
  • Use the “git pull <remote-name> <branch-name> –rebase” command.
  • Show the list of all existing branches.

Step 1: Switch to Git Repository
At first, execute the “cd” command along with the required Git repository path and navigate to it:

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

Step 2: Check Remote URL List
Then, display the list of existing remote URLs through the “git remote” command along with the “-v” option:

$ git remote -v

Step 3: Git Pull Operation Without Merge
Next, execute the “git pull” command to download the copy of the remote repository to the local machine:

$ git pull origin master --rebase

Here, the:

  • origin” is the name of a remote URL.
  • master” is the name of the local machine.
  • –rebase” option is used to download the remote branch without merging with the local branch.

According to the provided output, the remote “master” branch is pulled successfully without merging:

Step 4: List Remote Branches
To verify the newly pulled remote branch into the local repository, run the “git branch” command:

$ git branch -a

In the below-given output, the pulled “master” exists in the branch list:

Here, we have compiled the process to Git pull the remote branch without merging it.

Conclusion

To perform the Git pull remote branch without merging it, first, switch to the Git local repository and view the list of existing remote URLs. Then, run the “git pull <remote-name> <branch-name> –rebase” command to pull the remote branch without merging it. Lastly, show the list of all existing branches. In this study, we have illustrated the method of performing the Git pull remote branch without merging it.

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.