[英]Configure Git to notify about stashed changes
是否可以配置Git来提醒我,当我启动一些Git命令时,我的存储空不是空的,比方说,例如,当我切换分支时?
Some commands can invoke githooks . 有些命令可以调用githooks 。
Switching branches is usually done by git checkout <branch>
. 切换分支通常由
git checkout <branch>
。 The hook post-checkout
is invoked if it exists and is executable when git checkout
is run. 挂钩
post-checkout
是否存在,如果存在则可以调用,并且在运行git checkout
时可执行。 Copy the following script and paste to .git/hooks/post-checkout
, and run chmod 755 .git/hooks/post-checkout
. 复制以下脚本并粘贴到
.git/hooks/post-checkout
,然后运行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. 然后当你运行
git checkout <branch>
,将运行git stash list
并打印存储条目(如果有的话)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.