Git: Create a duplicate branch of master

I worked on upgrading a web service from JDK 1.6 to JDK 1.8 and was successful (that’s something I need to write a post on); however, I wanted to make sure I could revert back to pre-1.8 in case it breaks in production. The solution was to create a clone or duplicate of master before I merged the branch.

This would then allow me to merge that branch if needed. Here’s how:


git checkout -b java6-branch origin/master

And then, it needs to be pushed so others can access it:


git push origin java6-branch

That’s it. You can double-check by logging into your Git site. 🙂

P.S. Best practice is to name your branches in lowercase and in groupings (i.e. foo/bar1, foo/bar2).

Leave a Reply

Your email address will not be published. Required fields are marked *