gpt4 book ai didi

git - 从 Makefile 跟踪分支更改

转载 作者:太空狗 更新时间:2023-10-29 14:32:46 24 4
gpt4 key购买 nike

对于 Makefile 而言,如何发现当前分支的 HEAD 发生了变化?

我正在寻找类似这样的东西,但对于通用的当前分支:

all: report.txt

report.txt: .git/refs/heads/master
touch report.txt

最佳答案

.git/HEAD 给出了当前分支的 ref,所以你可以解引用 .git/HEAD,得到实际的当前分支 ref。

all: report.txt

current := $(shell cut -c6- .git/HEAD)

report.txt: .git/${current}
touch report.txt

请注意,如果您切换分支,您将检测到更改,即使新分支与前一个分支在同一提交上也是如此。

关于git - 从 Makefile 跟踪分支更改,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24320276/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com