惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

C
Check Point Blog
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
C
CERT Recently Published Vulnerability Notes
Apple Machine Learning Research
Apple Machine Learning Research
酷 壳 – CoolShell
酷 壳 – CoolShell
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
J
Java Code Geeks
Jina AI
Jina AI
雷峰网
雷峰网
M
MIT News - Artificial intelligence
小众软件
小众软件
H
Help Net Security
The Register - Security
The Register - Security
T
Tailwind CSS Blog
D
DataBreaches.Net
大猫的无限游戏
大猫的无限游戏
有赞技术团队
有赞技术团队
G
Google Developers Blog
云风的 BLOG
云风的 BLOG
Google DeepMind News
Google DeepMind News
月光博客
月光博客
Project Zero
Project Zero
P
Proofpoint News Feed
S
Security @ Cisco Blogs
L
LINUX DO - 最新话题
I
InfoQ
Vercel News
Vercel News
V
Vulnerabilities – Threatpost
S
Schneier on Security
Spread Privacy
Spread Privacy
Hugging Face - Blog
Hugging Face - Blog
D
Docker
博客园 - 【当耐特】
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
T
The Blog of Author Tim Ferriss
博客园 - 聂微东
宝玉的分享
宝玉的分享
Recorded Future
Recorded Future
K
Kaspersky official blog
L
LINUX DO - 热门话题
Stack Overflow Blog
Stack Overflow Blog
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
腾讯CDC
A
About on SuperTechFans
D
Darknet – Hacking Tools, Hacker News & Cyber Security
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
GbyAI
GbyAI
Schneier on Security
Schneier on Security
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
B
Blog RSS Feed

ZDDHUB

PixelsMeasure 开发第二年总结 PixelsMeasure 开发一年总结 Swift/SwiftUI 踩坑记 为什么说 GPT 利好程序员 ChatGPT 编程实现 Web 数字水印 Web 数字水印探究 Micro Frontends for Mobile URL 加载系统(URL Loading System) Protocol Buffers GraphQL 从 0 到 1 开发一款 IOS 应用 - Swift MV* 软件设计架构 学习一个新技巧需要多久? 不停机数据库迁移 Rspec 如何 mock update 方法更新自己? Rails 使用 mysql2 出现的段错误 使用 Docker-compose 部署 Rails 应用到生产环境 Cocoa troubleshooting 独孤九剑 Dit (0x05) - 终端篇 Gem-based Jekyll theme 开发小记 Miscellaneous 前端手记 TodoMVC 之 Redux 篇 前端手记 TodoMVC 之 Server 篇 前端手记 TodoMVC 之 React 篇 前端手记 TodoMVC 之 CSS 篇 独孤九剑 Dit (0x04) - 测试篇 独孤九剑 Dit (0x03) - 缓存篇 英语小抄 LLDB debug Golang Make mistakes 大牛俱乐部上线啦 独孤九剑 Dit (0x02) - 数据结构篇 独孤九剑 Dit (0x01) - 总决 独孤九剑 Dit (0x00) - 我为什么要做 Dit 零值强制类型转换的使用 终端颜色输出重定向 Go语法简略 - 正则表达式 Makefile Go语法简略 - Duck框架探索 Go语法简略 - 依赖注入 Go语法简略 - web应用框架 Go语法简略 - 反射 Go语法简略 - 面向对象 Go语法简略 - goroutine Go语法简略 - 方法和接口 Go语法简略 - 基础篇 大牛 轻松科研 未来这几年 为 Android Studio 创建图标 Shell Vim 金庸答百问 论拖延症 Flex, A fast scanner generator 有理想的人 从虚拟到现实 常用视频转接口 Recognizer configuration on CentOS 整个世界清静了 《Python源码剖析》读书笔记
Git
zddhub · 2015-03-03 · via ZDDHUB

这里记录我容易忘记的Git命令

9. 按目录配置用户名和邮箱信息

可能你会有这种需求,在某一个目录下放置多个项目,所有项目共享一个用户名和密码。在其他项目,用默认全局的用户名和密码,怎么做呢?includeIf 可能帮的上忙。先在全局的 ~/.gitconfig 文件中加入:

[includeIf "gitdir:~/Projects/another-project-path/"]
    path = .gitconfig-another-project-name

再在 ~/.gitconfig-another-project-name 中为 another-project-folder 配置特别的用户名和密码即可。

参考:https://stackoverflow.com/questions/21307793/set-git-config-values-for-all-child-folders/37167110

8. 寻找丢失的commit

checkout或者rebase后,可能会丢失之前的commit,使用git reflog可列出所有提交的commit。

$ git reflog
$ git checkout -b newbranch commit-id

7. long path name on windows

$ git config --system core.longpaths true

6. git sha1

$ echo hello | git hash-object --stdin
ce013625030ba8dba906f756967f9e9ca394464a

$ printf 'blob 6\0hello\n' > test.txt

or

$ echo -en "blob 6\0hello\n" > test.txt

$ openssl sha1 test.txt
SHA1(test.txt)= ce013625030ba8dba906f756967f9e9ca394464a

5. git log

$ git log v2.5..        # commits since (not reachable from) v2.5
$ git log test..master  # commits reachable from master but not test
$ git log master..test  # commits reachable from test but not master
$ git log master...test # commits reachable from either test or
                        #    master, but not both
$ git log --since="2 weeks ago" # commits from the last 2 weeks
$ git log Makefile      # commits that modify Makefile
$ git log fs/           # commits that modify any file under fs/
$ git log -S'foo()'     # commits that add or remove any file data
                        # matching the string 'foo()'
$ git log --no-merges   # dont show merge commits

$ git log --pretty=format:'%h was %an, %ar, message: %s'

$ git log --pretty=format:'%h : %s' --graph

# sort
$ git log --pretty=format:'%h : %s' --topo-order --graph
$ git log --pretty=format:'%h : %s' --date-order --graph

4. 问责

$ git blame filename
$ git blame -L 160,+10 filename

3. 克隆一个裸仓库

$ git clone --bare ~/proj proj.git
$ git commit --amend --author "Author <zddhub@gmail.com>"

1. Git 配置

# 更改你的编辑器
$ git config --global core.editor vim
# 添加别名
$ git config --global alias.last 'cat-file commit HEAD'
# 添加颜色
$ git config color.branch auto
$ git config color.diff auto
$ git config color.interactive auto
$ git config color.status auto
Or
$ git config color.ui true
# 日志格式
$ git config format.pretty oneline
# 提交者信息
$ git config --global user.name zdd
$ git config --global user.email zddhub@gmail.com

如果你喜欢这篇文章,欢迎赞赏作者以示鼓励