Git Pull Branch from GitHub

Git Pull Branch from GitHub

Pulling a Branch from GitHub

You may continue to work on the new branch in our local Git.

Let’s pull from the GitHub repository again, so that the code is up-to-date:

Example:

Open up the Command shell to use Git.

For Windows, Git bash is used, which comes included in Git for Windows. For Mac and Linux the built-in terminal is used.

Do make a check if Git is properly installed or not:

[user @localhost] $ it –version

git version 2.30.2.windows.1

If Git is installed, something like this is shown git version X.Y

[user @localhost] $git config –global user.name “Tutorial-test”

[user @localhost] $ git config –global user.email test@tutorial.com

You can change the user name and e-mail address on your own.

Now the main branch is updated. And a new branch is available on GitHub.

Let’s check the status:

Example:

[user@localhost] $ git status

On branch master

Your branch is up to date with ‘origin/master’.

nothing to commit, working tree clean

And confirm which branches we have, and which branch are we currently:

Example:

[user@localhost] $ git branch

 * master

There is no new branch on the local Git. But it is available on GitHub. Therefore, by using the -a option all local and remote branches can be seen:

Example:

[user@localhost] $ git branch -a

* master

 remotes/origin/html-skeleton

 remotes/origin/master

It is observed that the branch html-skeleton is available remotely, but not in the local git. Let’s check :

Example:

[user@localhost] $ git checkout html-skeleton

Switched to a new branch ‘html-skeleton’

Branch ‘html-skeleton’ set up to track remote branch ‘html-skeleton’ from ‘origin’.

And check everything is updated:

Example

[user@localhost] $ git pull

Already up to date.

Which branches are we having, and where are we working from?

Example

[user@localhost] $ git branch

* html-skeleton

  Master

Now, open the editor and confirm that the changes from the GitHub branch are carried over.