Git Questions – How do I switch branches without losing my work?

Trisha Gee

We regularly get questions about how to achieve a particular thing – as developers there are parts of our workflow which trip us up, that our tools can help us with if we understand how.  So we’ve decided to start answering these real world questions with videos showing what to do.

The first video features me, Trisha Gee (Developer Advocate for IntelliJ IDEA) and Gary Hockin (Developer Advocate for PhpStorm) answering the question “How do I switch branches without losing the code I was working on?”. Through frequent battles with Git I have learnt there’s always more than one way to do things, so in this video we present two different options.  We’re also two advocates using two different IDEs, coding in two different languages – many challenges we face as developers aren’t unique to our language or tool.

We’re really interested in what you think of this more informal format – it’s more like a video podcast than a screencast. We’d also love to hear what questions or problems you’d like us to tackle in future videos.

Comments below can no longer be edited.

16 Responses to Git Questions – How do I switch branches without losing my work?

  1. Anon says:

    January 16, 2017

    Why is the resolution of this video so low?

    • sebastian says:

      August 1, 2018

      It’s 720p ?!

  2. Dimitar Dimitrov says:

    January 17, 2017

    Please keep writing. I find it much easier to read than to follow a video.

  3. Yuri Volkov says:

    January 17, 2017

    I agree with Dimitar: please keep writing.
    Two paragraphs about that “two options” would be far quicker to find and to understand than watching video (which I personally didn’t do although I’m curious. Think of this!)

  4. Zoot99 says:

    January 17, 2017

    I like the video better than just text, because it shows you what menu items or buttons are being clicked as you switch branches.

  5. Gauthier P says:

    January 17, 2017

    I like this new format, it can help new comers to discover the IDE easily and it’s more interactive than a blog post. Also, it’s more friendly than a long blog post explaining how to do things (moreover, the Doc already explains everything).

    Looking forward for the next video !
    And I can see that IDEA still have repainting issues :’) But I was pretty sure this issue was fixed now ( “)

    • Trisha Gee says:

      January 18, 2017

      I think the repainting issue here is simply because Gary switched themes without restarting, or it might be because he switched themes but didn’t update his editor settings. I don’t think it’s a problem for most people.

      • Gauthier P says:

        January 20, 2017

        I sometimes switch between themes, and it automatically change the color scheme (when using the color scheme associated with the look and feel) and even without restarting, the problem doesn’t occurs most of the time. 🙂

  6. Trisha Gee says:

    January 18, 2017

    Don’t worry, we will keep writing as well – this is an additional format, it won’t replace our traditional blogs and help documents. If people find it useful, we’ll keep doing it.

  7. cupakob says:

    January 19, 2017

    git stash

    and git stash apply or git stash pop

    do the same 😉

    • Trisha Gee says:

      January 19, 2017

      Yes, absolutely. These are two alternatives are good for those who prefer not to work directly with the command line (and they have other advantages/disadvantages as well).

  8. Ron says:

    January 27, 2017

    I have seen this now in several jetbrains videos that on the bottom the shortcut appears. What setting or plugin is that? Apart from that nice video about the git fork

    • Trisha Gee says:

      January 30, 2017

      It’s a plugin called Presentation Assistant. It’s really useful!

      • Ron says:

        January 30, 2017

        Thank you, I present a lot with live coding and I will start using this plugin.

  9. Leif Theden says:

    April 10, 2018

    Maybe do both? Spending 7+ minutes to watching a presentation to figure out what I could read in 1 minutes is a waste of time.

  10. shakhzod says:

    February 28, 2020

    Excellent, very helpful

Subscribe

Subscribe for updates