In this tutorial, you will understand how to use the git pull to remote branch and get the updates to the local branch which means all the latest changes are being downloaded from GitHub or Bitbucket repository to your local machine drive.
Table Of Contents
Git is a repository for tracking all project source code updates and changes. It helps project managers to store and track all changes with commits so they can go back to any change that already happened before.
What is The Git Branch
The git branch defines another line in the development, something like another direction contains a new pointer in the development.
Actually, the default name of the git branch is “master”, and to define a new branch you just need to run the following git command
git branch [BRANSH-NAME]
This command is only for creating a new branch without switching from the old branch. And to switch to this branch you just need to use the “switch” word beside the name of the branch.
git switch [BRANSH-NAME]
Git Pull Remote Branch to Local Branch
The git pull command already fetches and merges the online repository with the local branch. So if you already working with a source code you can download the latest changes of your project repository from the git control system using one command.
But to do that you have to know the current branch you already work on to put it beside the “origin” word in the git command
git pull origin [BRANSH-NAME]
To download and merge the latest updates in the tree from the online repository you just need to run this command
git pull origin master
To add another branch to your project use
git branch [branch-name]. And to switch between other branches you have to use
git switch [branch-name].
The default branch name in the git control system is the “master“.
When you use the git pull command it already merges the new changes with the local branch. Also, there is another way to pull with the force command, check the git pull force tutorial.