【无标题】

git在没有设置全局别名的话,将多个项目下设置相同的别名的脚本

bash 复制代码
#!/bin/bash

# List of aliases to add
aliases=(
    "co = checkout"
    "ci = commit"
    # Add more aliases here as needed
)

# Loop through each directory in the current directory
for dir in */; do
    # Enter the directory
    cd "$dir"

    # Check if it's a Git repository
    if [ -d ".git" ]; then
        # Enter the Git repository
        cd .git

        # Add aliases to the local config file
        for alias in "${aliases[@]}"; do
            git config --local alias."${alias%%=*}" "${alias#*=}"
        done

        # Go back to the parent directory
        cd ..
    fi
done
相关推荐
jiayong235 小时前
Git 核心概念:Tag 与 Branch 的本质区别
git
Serene_Dream9 小时前
git 合并冲突的分支
git
我是一只puppy9 小时前
使用AI进行代码审查
javascript·人工智能·git·安全·源代码管理
玄同76510 小时前
Git常用命令指南
大数据·git·elasticsearch·gitee·github·团队开发·远程工作
十步杀一人_千里不留行13 小时前
Git提交前ESLint校验实践(Husky + lint-staged)
git·github
hh随便起个名16 小时前
适合小白的git的基础使用方法
git
我会一直在的16 小时前
Devps持续集成
git·ci/cd
CoderJia程序员甲17 小时前
GitHub 热榜项目 - 日榜(2026-02-08)
git·ai·开源·llm·github
Serene_Dream19 小时前
git 常用命令
git
jiayong2319 小时前
Detached HEAD 状态详解
git