Technology Insights

How To Switch Between Git Branches From The Linux CLI

If you are using Git for version control then it is likely at some point you will have a project with multiple branches of code. The benefit of this is allowing various developers to work on different projects while providing an easier way to merge the code when the developers tasks are completed. One developer may be working strictly on big fixes that could need to be checked in daily while another developer may be working on a project that may take months to complete and git provides a system to merge these code branches together. Below is a quick reference for switching between Git code branches.

Technology Errors

git: Error: Some Local Refs Could Not Be Updated; Try Running ‘git remote prune origin’ To Remove Any Old, Conflicting Branches

Lately I have been working on a Ruby project that has a bunch of different branches that various developers are working on. One of the development servers has multiple virtual hosts and at certain points in the code release cycle the various virtual hosts could be completely split from the main branch of Ruby code either because of a bug fix, a specific feature, or any number of other reasons. The other night I needed to bring one of the virtual hosts to a near production release to test some features of a product that uses the web application to record data and when I attempted to “git pull” I received an error which is described in detail below along with what I ended up doing to resolve the problem.

Technology Insights

Delete a Remote Branch from GitHub

Deleting a remote branch from a GitHub account is easy though I have seen numerous ways listed and only one of them worked for me possibly because of syntax errors. Sometimes a temporary branch may be necessary because of adding a contractor to work on a project or possibly just to pause the current projects to get something pushed out quickly.

Use the syntax below to remove a branch from GitHub.com.

Technology Errors

msysgit clone Error – fatal: Cannot update the ref ‘HEAD’

I wanted to start syncing a git project to my Windows XP laptop so I installed msysgit because of the good things I have heard about it. The latest version was 1.6.2 so I figured that was a good place to start. Using a clone command I knew works on Linux since I use it all the time I attempted to clone a git repository from github onto the Windows PC. I ended up receiving the output below which is filled with errors.

Git Version:

bash

  1. git version 1.6.2.msysgit.0.186.gf7512