简体   繁体   English

配置Git以通知有关隐藏的更改

[英]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.

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