关于运维:GitHubGitLab-为不同的项目修改提交名字-username-和邮箱-useremail附批量处理脚本

6次阅读

共计 1016 个字符,预计需要花费 3 分钟才能阅读完成。

背景

大疫情的背景下,家里的电脑须要同时撑持本人和公司的我的项目,依据 GitHub/GitLab 网站的提交记录上看,其是依据邮箱来辨识用户的,所以有必要别离针对不同的我的项目设置不同的 Git 名字(user.name)和邮箱(user.email)。

解决方案

以 Git 我的项目 https://github.com/mazeyqian/mazey 为例:

cd /Users/X/Web/mazey

git config user.name "Your Name"
git config user.email "your@email.com"

验证一下批改后果:

cat .git/config

输入:

...
[user]
        email = your@email.com
        name = Your Name

而后此我的项目的提交信息就不再受全局设置的用户名和邮箱影响了。

批量批改

一键批量批改单个文件夹下所有 Git 我的项目,免去入手懊恼,批量执行文件下载地址:

https://github.com/mazeyqian/go-gin-gee/releases/tag/v1.0.0

# Example: MacOS
./change-git-user-mac-darwin-amd64 -path="/Users/X/Web" -username="Your Name" -useremail="your@email.com";

输入:

2022/12/18 14:31:49 Change git user...
2022/12/18 14:31:49 absolutePath: /Users/X/Web
2022/12/18 14:31:49 userName: Your Name
2022/12/18 14:31:49 userEmail: your@email.com
2022/12/18 14:31:49 result: - - begin - -
...
...
- - end - - - - - - - - - - - - - - - - -

All done.
参数 阐明
path 我的项目文件夹,将批量批改此文件夹上面的所有 Git 我的项目
username user.name
useremail user.email

参考

  1. Customizing Git – Git Configuration
  2. Git 查看和批改用户名和邮箱

版权申明

本博客所有的原创文章,作者皆保留版权。转载必须蕴含本申明,放弃本文残缺,并以超链接模式注明作者后除和本文原始地址:https://blog.mazey.net/2956.html

(完)

正文完
 0