Git Tricks–Getting a New Remote Branch–#SQLNewBlogger

Another post for me that is simple and hopefully serves as an example for people trying to get blogging as #SQLNewBloggers.

This is probably more for me than anyone, but as I’ve been working in more team demos, I find I need to up my git skills. In this case, a fellow team member created a new branch, and I needed to get it on my local machine.

I know many git clients will make this easy, but I always like to see what happens at the CLI. This keeps my skills fresh, and I can see all the git output, some of which might be hidden in a client.

In this case, the team member had created a branch on Github. I’ll demo this by creating my own branch as feature/demotest. I see the branch online.

2020-08-18 15_30_25-way0utwest_dbascripts at feature_demotest

However, I don’t see it locally.

2020-08-18 15_31_00-cmd

If I know the name, I get fetch this, or pull it, from the remote. In this case, either of these code items will work.

git pull origin feature/demotest


git fetch origin feature/demotest

Once I do this, I can checkout the branch, which will match the remote with this code:

git checkout feature/demotest

2020-08-18 15_32_56-cmd

Now it’s a branch that is tracking the remote with my local copy.


This was a quick Google search to figure out how to do this, but since I’ve had to search a couple times in the last month, I decided to write this and cement the knowledge in my head. At least, I hope it does.

This took about 5 minutes to write and demo. A quick thing, but a good way to show some learning and knowledge on your blog.

About way0utwest

Editor, SQLServerCentral
This entry was posted in Blog and tagged , , , . Bookmark the permalink.