Announcement

Collapse
No announcement yet.

Named stashes

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Named stashes

    I've created a script to ease the stash->rebase->unstash cycle:

    #!/bin/bash
    git stash save
    git rebase origin/develop
    git stash pop

    This works as intended except for when there are no uncommited changes, in which case the first command will not create a stash and `git stash pop` will then delete the latest already exisiting (if any).

    To work around this i've been trying to find a way to name identify a stashes, but it seems that is not possible and they are always numbered like for instance `stash@{0}` for the most recent (and then increasing numbers for the older ones).

    Any thoughts?

    Thanks!
    Geir

  • #2
    Hmm, the exit code of git stash does not say anything.
    What about something like:

    #!/bin/bash
    if (git stash | grep -q "^No local changes")
    then
    git rebase origin/develop
    else
    git rebase origin/develop
    git stash pop
    fi

    Comment

    Working...
    X