Recently I discovered that git stash pop does not work as I expect / desire. git stash pop
merges between the current state and what's in the most recent stash.
I would like to have a command or script that would return me to the previous state to do git stash
.
That is, do the following.
Point 3 is especially problematic because git stash
does not save what branch you were on. With what I'm afraid it will not be possible without doing another script for an alternative git stash. With which I accept answers that do not solve this point.
In bash, the above would be something like this:
#!/usr/bin/env bash
#1a directorio sucio
DIR_SUCIO=$(algunos_comandos)
if [ $DIR_SUCIO -ne 0 ]; then
echo "El directorio actual está sucio"
exit 1
fi
#1b staging area
STG_AREA=$(algunos_comandos)
if [ $STG_AREA -ne 0 ]; then
echo "La área de staging no está vacía"
exit 1
fi
#2 Obtener el commit necesario
COMMIT=$(algunos_comandos)
git checkout $COMMIT
#4
git stash pop
For 1a git status
does not work because it returns 0 whether the directory is empty or not. The same happens with 1b. If I do not find an appropriate command, I will have to resort to making parse of git status
.
Point 2 I see even more difficult.