Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

Switch Between Two Git Branches – Quickest Way!

Usually, when you want to Switch branches, you use git checkout branch-name.

But let’s say you’re working with two branches and want a quick way to switch between them.

You wouldn’t want to type the name of the branch every time you want to switch to it.

That’s where the git checkout - comes in.

Let’s see how it works.

How does git checkout - work?

The git checkout - command allows you to switch to the previous branch you were on.

  • Let’s say you are currently on branch-A.
  • You run git checkout branch-B to switch to it
  • After working on branch-B you decide to switch back to branch-A, but you don’t remember the branch’s name or you just want to save a bunch of keystrokes
  • So you type git checkout - which will take you back to the last branch you were in before switching to branch-B. In this case, branch-A.

Essentially, git checkout - toggles between two branches: the current one and the branch you were in before the most recent branch switch.

 Check out this video for a showcase of this functionality:




This post first appeared on Neutron Dev, please read the originial post: here

Share the post

Switch Between Two Git Branches – Quickest Way!

×

Subscribe to Neutron Dev

Get updates delivered right to your inbox!

Thank you for your subscription

×