shell的if多条件

1 、git的版本HEAD解释

bash 复制代码
#如下都是一样的获取最近一次提交的hash值
git log -1 | grep commit
git rev-parse HEAD
git rev-parse HEAD^
git rev-parse HEAD^1
git rev-parse HEAD~
git rev-parse HEAD~1




#如下都是一样的获取最近n次提交的hash值
git rev-parse HEAD~n
git rev-parse HEAD^n
git log -n | grep commit

2、shell的if多条件

bash 复制代码
		# if [[ -f "${target_dir}/${git_dir}/tmp/hash.txt" && -f "${target_dir}/${git_dir}/tmp/mod.txt" ]] && [[ $(cat "${target_dir}/${git_dir}/tmp/hash.txt") == $(git rev-parse HEAD^) ]]; then
		if [[ -f "${target_dir}/${git_dir}/tmp/hash.txt" && -f "${target_dir}/${git_dir}/tmp/mod.txt" ]] && [[ $(cat "${target_dir}/${git_dir}/tmp/hash.txt") == $(git rev-parse HEAD) ]]; then
			echo "Okay"
		else
			echo "Fail"
		fi  

3、git文件权限检查开关

bash 复制代码
git config core.filemode false  #是去掉权限检查的情况  git status ./的时候
git config  --local  core.filemode false
git config  --local  unset core.filemode
相关推荐
深海鱼在掘金2 天前
Git 完全指南 —— 第1章:Git 概览与版本控制演进
git
开发者联盟league3 天前
安装pnpm
ssh
noravinsc3 天前
关于Git Flow
git
2601_961875243 天前
决战申论100题2026|最新|范文
linux·容器·centos·debian·ssh·fabric·vagrant
蜜獾云3 天前
在Git中配置用户名和密码
git
scx_link3 天前
通过git bash在本地创建分支,并推送到远程仓库中
开发语言·git·bash
南大白3 天前
IntelliJ IDEA 运行时的 JVM 本地内存溢出崩溃
git
码农小旋风3 天前
Claude Code 基础用法大全:对话、分析、修改、测试、Git 和工作流
人工智能·git·chatgpt·claude
南大白3 天前
Git 撤回提交完整方案
git
像风一样的男人@3 天前
python --实现代理服务器
git·ui