Don’t you hate it when you’re gonna push your code to git repository and find out someone just push earlier and you must do git pull and re-push again ?

I made a simple and dumb bash script to do a git pull when git push is failed because you need to git pull first. Well, this is the script.

git push
if [ $? -eq 0 ]
then
    echo "DONE PUSHING"
else
    echo ""
    echo "OH SHIT. SOMEBODY ALREADY PUSH TO REPO"
    echo ""
    git pull
    if [ $? -eq 0 ]
    then
        echo ""
        echo "DONE PULLING. LETS RE-PUSH THAT CODE"
        echo ""
        git push
    else
        echo ""
        echo "OH NO! THERE'S SOME MERGE CONFLICT. FIX IT FIRST!"
        echo ""
    fi
fi

On linux you could just make some alias to run the script. On windows and using CMDER, just edit the aliases file and add gp=sh "path/to/your/file.sh"

I hope you find it helpful.