简体   繁体   中英

Configure Git to notify about stashed changes

是否可以配置Git来提醒我,当我启动一些Git命令时,我的存储空不是空的,比方说,例如,当我切换分支时?

Some commands can invoke githooks .

Switching branches is usually done by git checkout <branch> . The hook post-checkout is invoked if it exists and is executable when git checkout is run. Copy the following script and paste to .git/hooks/post-checkout , and run chmod 755 .git/hooks/post-checkout .

#!/bin/bash

oldrev=$1
newrev=$2
flag=$3

# list stashes if switching branches
if [[ "${flag}" = 1 ]];then
    git stash list
fi

Then when you run git checkout <branch> , git stash list will be run and print the stash entries if any.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM