Git

How to Pull Changes From a Specific Branch in Git

Git is the collaborative development environment used to track the changes in the project directory or files. In the local Git repository, users have local branches, which are used to track a remote branch on the remote repository. However, sometimes users need to track the updates of a specific remote branch that is placed in the remote repository.

This study will describe the procedure for pull changes from a specific branch in Git.

How to Pull Changes From a Specific Branch in Git?

For instance, we have a local branch named “main”, which is set to track a remote branch with a similar name in our Git local repository. To pull changes from the specified directory, check out the below section.

Step 1: Launch Git Bash

Search the “Git Bash” with the help of the “Startup” menu and open it on your system:

Step 2: Navigate to Git Repository

Next, navigate to the specified Git repository in which you need to pull changes using the below command:

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

Here, “mari_khan” is our Git local repository:

Step 3: Pull Changes

Now, pull all changes from a specific branch through the below-provided command. Here, the “origin” and “main” remote branches of our “mari_khan” remote repository from where the changes are pulled and merged into the local checked-out branch:

$ git pull origin main

The below output indicates that everything is up-to-date and we have already pulled changes from a specific branch “main”. However, in your case, the output might be different:

We have provided the method of pulling changes from a specific branch in Git.

Conclusion

To pull changes from a specific branch in Git, first, launch the “Git Bash” on your system. Next, move to the Git local repository using the “cd” command. After that, execute the “$ git pull origin main” command to pull all changes from the origin and main branch and merge them in the local checked-out branch. In this study, we have illustrated the procedure of pulling changes from a specific branch in Git.

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.