Git STASH Tutorial

แชร์
ฝัง
  • เผยแพร่เมื่อ 20 มิ.ย. 2024
  • Learning any Git technique can be this easy: learngit.io/
    -----
    What is the Git stash command, and how do you use it? Git stash allows you to set aside in-progress changes for later. In addition to simply saving drafts of your work, stashes can be manipulated in interesting ways to improve your Git workflow. In this tutorial I'll explain how to use Git stash (including common commands such as "git stash pop", "git stash list", "git stash show", "git stash drop", "git stash clear", and "git stash branch"). As always, I'll illustrate the concepts with live animations alongside the actual commands.
    WRITTEN ARTICLE & REFERENCE: www.themoderncoder.com/git-st...
    GIT STARTER GUIDES: www.themoderncoder.com/git/
    CHAPTERS
    0:00 Intro
    0:15 Git stash use-cases
    1:12 Git stash: basic example
    3:26 Multiple stashes & naming stashes
    5:16 Git stash branches
    6:00 Deleting stash entries
    6:20 Git stash merge conflicts
    MY TECH
    2020 M1 MacBook Air (I have the 512GB variant): amzn.to/3TTIBsE
    AirPods Pro: amzn.to/3sRLUo5
    Chair: amzn.to/3zJI9Fa
    Gaming headset: amzn.to/3zwbT8i
    Headphones (newer model): amzn.to/3Ub5reT
    Keyboard: amzn.to/3FOOOC7
    Mouse: amzn.to/3WhMFV9
    Monitor: www.dell.com/en-us/work/shop/...
    Monitor arm (newer model): amzn.to/3gXnlUa
    Webcam: amzn.to/3zxxwp0
    TECH ACCESSORIES
    Laptop stand: amzn.to/3NuyqZ5
    Mouse pad/mat: amzn.to/3U9QFVO
    KVM switch: amzn.to/3gZmpP0
    PC case: amzn.to/3Fx4Hg5
    Under desk drawer: amzn.to/3WloFAo
    VIDEO GEAR
    Camera: amzn.to/3WkbiRe
    Lens: amzn.to/3zxiTC4
    Microphone: amzn.to/3SSUoWE
    Main key light: amzn.to/3WhZbny
    Secondary light: amzn.to/3fpRefx
    Some of the links above are affiliate links which means, at no extra cost to you, I will make a small commission if you click them and make a qualifying purchase. Thanks for supporting the channel.
    MUSIC CREDITS
    Music from Uppbeat (free for Creators!):
    uppbeat.io/t/danijel-zambo/st...
    License code: FC7DKHETA2DJGCMY
    ICON CREDITS
    Icons from Flaticon
    ABOUT ME
    An experienced tech professional with experience including software engineering management, and software engineering. Formerly at Amazon for over 6 years, and currently living in NYC.
    FOLLOW
    Blog: www.themoderncoder.com
    Twitter: / themoderncoder
    #git #linux #programming #github

ความคิดเห็น • 40

  • @IvanIvanov-ub3qe
    @IvanIvanov-ub3qe ปีที่แล้ว +12

    Nice video. I think you can mention that git stash -u can add all the files (tracked and untracked) without the need to perform git add . .

  • @mehdizahedi2810
    @mehdizahedi2810 5 วันที่ผ่านมา

    Your videos are an absolute gem. Thank you

  • @AkinBelieve
    @AkinBelieve หลายเดือนก่อน +3

    Excellent. Very few can deliver technical information with this sort of precision. Please, please, please keep these coming.

    • @themoderncoder
      @themoderncoder  หลายเดือนก่อน +2

      Appreciate the compliment! These vids end up taking a ton of time to make, but I’m committed to keeping them going at least once a month. Hopefully I can find a rhythm for 2 a month, but we’ll see…

  • @gadgetsexplain
    @gadgetsexplain ปีที่แล้ว

    Very useful teaching method

  • @treequin
    @treequin ปีที่แล้ว

    Awesome video! The animations and layout are superb, they made it all perfectly clear to me.

    • @themoderncoder
      @themoderncoder  ปีที่แล้ว

      Awesome, appreciate you saying that

  • @knecks7374
    @knecks7374 หลายเดือนก่อน

    Absolutely Awesome Big man! thanks

  • @Sudhakar-msr
    @Sudhakar-msr ปีที่แล้ว

    Animated way of explaining the stuff really helps. keep going. looking forward for much more git topics. subscribed

  • @juanandrew1356
    @juanandrew1356 ปีที่แล้ว

    easy to understand, thanks sir

  • @magic0x0
    @magic0x0 ปีที่แล้ว

    Great tutorial 😮 Thank you 🙏🏻

  • @radvilardian740
    @radvilardian740 11 หลายเดือนก่อน

    Bro, ur git videos is incredibly azing, This saves lots of times to learn those useful command and understanding how it works, very much appreciated bro, these are all meats..

  • @roychang9506
    @roychang9506 ปีที่แล้ว +1

    subscribed. your git tutorial is a gem please keep it up

    • @themoderncoder
      @themoderncoder  ปีที่แล้ว +1

      Thanks! I'm releasing more Git videos, so I hope those help as well

  • @daumtto
    @daumtto 2 หลายเดือนก่อน

    good explanation

  • @yssplays2620
    @yssplays2620 19 วันที่ผ่านมา

    new subscriber. best explain very very very nice

    • @themoderncoder
      @themoderncoder  19 วันที่ผ่านมา

      Thank you so much 🙂

  • @juandavidcardenas1253
    @juandavidcardenas1253 ปีที่แล้ว

    Thanks a lot, It´s very useful. I was thinking how if you don't know the different git features like this, you might miss out on being more productive.

  • @nishikantwairkar6866
    @nishikantwairkar6866 2 หลายเดือนก่อน

    too good

  • @FullMetalAlgorithmist
    @FullMetalAlgorithmist 3 หลายเดือนก่อน

    Hi, I have a question. Is the stack data specific to a particular branch, or is that stack stored globally across all branches? If i do git stash in one branch, and then if i switch branch and pop the stack there, what will happen?

    • @themoderncoder
      @themoderncoder  3 หลายเดือนก่อน

      Stash's are one stack per repository. So if you create a stash on one branch, switch branches, then pop the stash, it'll apply those changes into the working directory.

    • @FullMetalAlgorithmist
      @FullMetalAlgorithmist 3 หลายเดือนก่อน

      @@themoderncoder Great, thanks!

  • @gentjanshtjefni4368
    @gentjanshtjefni4368 หลายเดือนก่อน

    can i pop the stash on another branch?

    • @themoderncoder
      @themoderncoder  หลายเดือนก่อน

      Yeah go for it. Stash on one branch, switch branches, then pop/apply the stash. Should work fine

  • @OpenDeepLearning
    @OpenDeepLearning ปีที่แล้ว

    I am curious about you and your career / mind. Why would you restart your TH-cam account? I mean, I think you earned a lot of money working on Amazon, right?

    • @themoderncoder
      @themoderncoder  ปีที่แล้ว

      The high-level reason is that TH-cam is certainly not about the money

    • @OpenDeepLearning
      @OpenDeepLearning ปีที่แล้ว

      @@themoderncoder but about what?

  • @harikrishnan9967
    @harikrishnan9967 หลายเดือนก่อน

    Hi bro i have one issue while cherry pick what is happening na example my bug fix is in fix1 branch which dev branch and i need to movie that in production branch so when i moved this thing in that prod branch it error while im compiling because of in prod old code is there and dev every person doing new changes are there my cherry pick changes are moved to some other lines so help me to resolve this bro

    • @themoderncoder
      @themoderncoder  หลายเดือนก่อน

      I'm not 100% sure I understood your question, but a suggestion would be to rebase your "fix1" branch against production BEFORE cherry picking. This would at least minimize the amount of conflicting changes.

    • @harikrishnan9967
      @harikrishnan9967 หลายเดือนก่อน

      @@themoderncoder im not talking about conflict, after resolving the conflict while I'm compile it is showing some errors because of cherry pick is stored in wrong lines in files

  • @user_account3841
    @user_account3841 6 หลายเดือนก่อน

    How to roll back when a stash is pulled off?

    • @themoderncoder
      @themoderncoder  6 หลายเดือนก่อน

      It's not so easy to undo an accidental stash pop. There are two things to undo: 1) The stash was dropped from your stash list and needs to be recovered. 2) You need to rollback the modifications in your working directory that were added by the stash. Step 1 can be solved using something like this to recover the stash: copyprogramming.com/howto/undoing-accidental-git-stash-pop. But for step 2, it might be a matter of manually using "git restore" to remove any modifications you don't want. If anyone here in the comments know's a better was for step 2, let us know.

  • @stuck1a
    @stuck1a 3 หลายเดือนก่อน +1

    I dont get it why everyone want to use all that time-consuming and confusing version control systems. Back in the 90s we were also able to work in teams without all that fancy things. It's so annoying to spend hours to solve dozens of conflicts before each pull request.
    After all, imho it just promotes chaos, so that everyone just codes whatever he wants instead of coordinating properly

    • @flexflex7600
      @flexflex7600 หลายเดือนก่อน +2

      Lol

    • @ejovo
      @ejovo หลายเดือนก่อน

      Lol

  • @xxcrypt234
    @xxcrypt234 ปีที่แล้ว

    nice!