Git Stash Tutorial ~ How to Shelve Changes for Later

Поделиться
HTML-код
  • Опубликовано: 14 окт 2024
  • Git Stash is a feature in Git that allows you to save changes that are not ready to be committed but need to be temporarily set aside. This git stash tutorial for beginners will show you exactly how to use git stash to temporary shelve changes.
    This can be useful when you want to switch branches or work on a different task without committing your current changes.
    Here are the main commands associated with Git Stash:
    1. git stash save "message":
    This command is used to stash changes in your working directory. The message is optional but can be helpful for identifying the stash later.
    git stash save "Work in progress on feature X"
    2. git stash list:
    Shows a list of stashes you've created. Each stash is assigned a unique identifier (e.g., stash@{0}, stash@{1}, etc.).
    git stash list
    3. git stash show:
    Displays the changes that are in the latest stash. This is useful for reviewing the changes before applying or popping the stash.
    git stash show
    4. git stash apply [stash_id]:
    Applies the changes from the specified stash on top of your working directory. If no stash ID is provided, it applies the latest stash.
    git stash apply stash@{1}
    5. git stash pop [stash_id]:
    Similar to `git stash apply`, but it also removes the applied stash from the stash list. If no stash ID is provided, it pops the latest stash.
    git stash pop stash@{2}
    6. git stash drop [stash_id]:
    Deletes a stash from the stash list. If no stash ID is provided, it deletes the latest stash.
    git stash drop stash@{0}
    7. git stash clear:
    Removes all stashes. This command is used when you want to clear all the stashed changes.
    git stash clear
    Git Stash is a convenient tool for temporarily saving changes, and you can use commands like `git stash list`, `git stash show`, `git stash apply`, `git stash pop`, `git stash drop`, and `git stash clear` to manage and interact with your stashes.

Комментарии • 7

  • @thankgodmudnoe3524
    @thankgodmudnoe3524 4 месяца назад

    A million thanks for the video

  • @AfmpJR
    @AfmpJR 5 месяцев назад +1

    Man! you did that so great. Thanks.

    • @cameronmcnz
      @cameronmcnz  5 месяцев назад +1

      The git stash command is the unsung hero of version control. Happy to share my affection for it!

  • @pravinprince3221
    @pravinprince3221 7 месяцев назад +1

    Thank you for the video sir
    We love your videos and thanks for the effort sir
    it is so helpful for the team and myself sir, thanks again

    • @cameronmcnz
      @cameronmcnz  7 месяцев назад

      Thanks so much for the kind words. Say 'Hi' to the team, and let me know if there are any good topics I should cover!

  • @umdesch4
    @umdesch4 5 месяцев назад +1

    Appreciate the info, and the Jocko Homo reference. :)

    • @cameronmcnz
      @cameronmcnz  5 месяцев назад

      You're an old schooler like me, obviously.