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
相关推荐
带娃的IT创业者5 小时前
Git commands I run before reading any code
git·开发工具·版本控制·编程技巧·代码审查
九成宫6 小时前
Git 与远程仓库实操记录:克隆、配置、分支推送与问题排查
笔记·git·ssh
武超杰15 小时前
Git 从入门到精通教程
git
程序员夏末16 小时前
【开源经历 | 第一篇】参与开源需要掌握的Git和Github指令
git·开源
SNOWPIAOP17 小时前
git status 出现中文乱码的解决方案等
git·乱码·postgres
qq_435287921 天前
第9章 夸父逐日与后羿射日:死循环与进程终止?十个太阳同时值班的并行冲突
java·开发语言·git·死循环·进程终止·并行冲突·夸父逐日
AIMath~1 天前
Git 子模块(Submodule)目录结构清除实战复盘
git
切糕师学AI1 天前
Ubuntu 下 Git 完全使用指南
linux·git·ubuntu
一袋米扛几楼982 天前
【Git】规范化协作:详解 GitHub 工作流中的 Issue、Branch 与 Pull Request 最佳实践
前端·git·github·issue
尘埃落定wf2 天前
# GitHub CLI:告别繁琐的 Git 命令,让开发更高效
git·github