Git 高级玩法

Git Blame

1
2
3
# 查看文件中,每一行的修改人和最后改动时间
$ git blame pom.xml
^e81ccde3 (BenedictJin 2018-06-04 11:16:19 +0800 1) <?xml version="1.0" encoding="UTF-8"?>

Git Branch

1
2
3
4
5
6
7
8
9
10
11
12
# 克隆当前分支,以此创建新的 branch,并切换
$ git checkout -b <branch>

# 重命名 branch 名称
$ git branch -m <old_name> <new_name>
$ git branch -m <new_name>

# 恢复删除掉的 branch
# 查看你上一次 commit SHA1 值
$ git reflog
# 恢复
$ git branch <branch_name> <sha1>

Git Cache

1
2
3
4
5
6
7
# 添加 .gitignore 文件之后,可能有些文件报错 `ignored tracked with git`
# 需要用 `git rm --cached` 进行删除
$ git rm --cached <file>

# 部分动态文件可能报错文件内容不一致 `the following files have staged content different from both the file and the HEAD`
# 需要增加 `-f` 参数进行强制删除
$ git rm --cached -f .idea/workspace.xml

Git Cherry-pick

1
2
# 指定某一次提交,合并到当前分支中
$ git cherry-pick 5738c801c

Git Checkout

checkout 的同时,创建新的 branch

1
$ git checkout -b <new_branch_new>

撤销某个文件的修改

1
$ git checkout -- <file>

Git Clone

1
2
# 只下载最后一次 commit 版本的代码
$ git clone --depth 1 https://github.com/asdf2014/yuzhouwan

Git Config

1
2
3
4
5
$ git config --global user.name "asdf2014"
$ git config --global user.email "asdf2014@apache.org"
$ git reset .
$ git add -A
$ git diff --staged

Git Commit

Allow Empty

1
$ git commit --allow-empty -m 'yuzhouwan.com'

Commit Merge

常规操作

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
$ git log --pretty=oneline

651cc60d971aba93bdde645b6331c33068462645 Merge branch 'master' of https://github.com/asdf2014/superset
415610958494446ccd37c0c87da98eba56af42ac Merge branch 'temp'
b881140282893fa4add183a2b3f2637968f95069 Merge branch 'master' into master
f2bf3160583533bd0dc5004f248f81251aa8c57e Add NUMERIC num_type (#2127)
6a0fefdbd542da4ea313313a191eadd1efe58faa Using the time zone with specific name for querying Druid
9cd38fa1eda63152c27b76c29dd948f29444b686 little code refactor in models.py (#2124)

$ git reset --soft HEAD~2 &&
$ git commit --edit -m "$($ git log --format=%B --reverse HEAD..HEAD@{1})"

[master fd41c16] Add NUMERIC num_type (#2127)
1 file changed, 1 insertion(+), 1 deletion(-)

# 更改之后的 commit 信息
fd41c1608579408fcd26d0dd03adf0d461599101 Add NUMERIC num_type (#2127)
6a0fefdbd542da4ea313313a191eadd1efe58faa Using the time zone with specific name for querying Druid
9cd38fa1eda63152c27b76c29dd948f29444b686 little code refactor in models.py (#2124)

踩到的坑

Failed to push some refs
描述
1
2
3
4
5
6
7
8
Username for 'https://github.com': asdf2014
To https://github.com/asdf2014/superset.git
! [rejected] ext_deprecation_warning -> ext_deprecation_warning (non-fast-forward)
error: failed to push some refs to 'https://github.com/asdf2014/superset.git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: '$ git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in '$ git push --help' for details.
解决
1
2
# 强制提交
$ git push -u origin ext_deprecation_warning --force

Commit Remove

1
2
$ git reset --hard <sha1-commit-id>
$ git push origin HEAD --force

Commit Change

只修改最后一次提交

1
2
3
4
5
6
7
# 格式
$ git commit --amend
$ git commit --amend -m "New commit message"
$ git commit --amend --author="Author Name <email@address.com>"
# 示例
$ git commit --amend -m 'remove warnings.simplefilter from cli.py into superset for PEP (#2137)'
$ git commit --amend --author="asdf2014 <asdf2014@apache.org>"

修改之前的提交信息

1
2
3
$ git rebase -i HEAD~2
pick xxxx
reword yyyy

修改提交的日期

1
2
3
4
5
6
7
8
9
# 查看当前时间
$ date -R
Mon, 07 Jan 2018 11:12:55 +0800

# 修改最后一次 commit 的提交日期
$ git commit --amend --date="Mon, 07 Jan 2018 12:00:00 +0800"

# 更新提交日期为当前时间
$ git commit --amend --date="$(date -R)"

Reset into Specific Commit

1
2
3
4
5
# It will make your local code and local history be just like it was at that commit. But then if you wanted to push this to someone else who has the new history, it would fail.
$ git reset --hard c14809fa

# It will make your local files changed to be like they were then, but leave your history etc. the same.
$ git reset --soft c14809fa

Squash Commits into a Single Commit

常规操作

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# 查看哪些 commits 需要进行合并
$ git log --pretty=oneline
# 合并最后 11 个 commit
$ git rebase -i HEAD~11
pick xxxx yyyy
pick xxxx yyyy
pick xxxx yyyy
# 将需要压缩的 commit 之前的 `pick` 替换为 `squash`
pick xxxx yyyy
squash xxxx yyyy
squash xxxx yyyy

$ git commit --amend -m 'The log length has exceeded the limit of 4 MB in Travis'
$ git push origin travis_log --force

# 如需解决冲突后,继续进行 rebase 操作,可执行
$ git rebase --continue
# 如果想中断 rebase 操作,则执行
$ git rebase --abort
# 更多细节
$ git rebase --help

其他

回滚
1
$ git reset --hard ORIG_HEAD
回滚上一次操作
1
2
3
4
5
$ git commit -m "Something terribly misguided"
$ git reset HEAD~
<< edit files as necessary >>
$ git add ...
$ git commit -c ORIG_HEAD
指定 commit number
1
$ git rebase <commit number>
合并 branch 改动到 master 中
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# 会将 branch 里的 commit 排到 master 的顶部,避免带 Merge 信息的 `空 commit` 出现
$ git checkout <branch name>
$ git rebase -i master

# 如果已经在当前 branch 执行了 git merge master,并解决了冲突,可以直接执行下面这行命令,完成 rebase 操作
$ git rebase --root --onto master --preserve-merges

# 万一出现太多的问题,难以解决,可以采用如下暴力的方式(在意 commit 信息的,请预先备份好)
$ git rebase --abort # 首先 abort 之前的 rebase 流程
$ git checkout code_refactoring
$ git checkout -b re2
$ git branch root bbb61e638b391d29 # 以当前 branch 未做任何修改之前的 commit 为基础,创建 root 分支
$ git checkout re2
$ git diff master > ../123.patch # 当前 branch 相对 master 已经做的修改打出 patch 文件
$ git checkout master
$ git checkout -b r2
$ git apply ../123.patch # 以 master 为基础,apply 分支上做的修改
$ git diff master
$ git status
$ git diff --name-status | wc -l # 确认修改的文件数 是否正确
$ git add .
$ git status
$ git diff master
$ git commit -m 'Improve `collection` related things that reusing a immutable object instead of creating a new object'
$ git status
$ git push origin r2:code_refactoring -f

Git Diff

Git diff two commits

1
$ git diff 1285c982 b0aaa7de > v3.4.6_vs_v3.4.10.patch

Git diff two branchs

1
$ git diff branch_1..branch_2

Git Fetch

Normal

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# Github 上对某一个开源项目进行 fork
https://github.com/apache/superset
https://github.com/asdf2014/superset (forked from apache/superset)

# 本地获取 fork 出来的 asdf2014/superset
$ git init
$ git remote add origin https://github.com/asdf2014/superset.git
$ git remote -v
origin https://github.com/asdf2014/superset.git (fetch)
origin https://github.com/asdf2014/superset.git (push)

## 发现并没有 airbnb/superset 的 origin/master,可以在直接往 asdf2014/superset 提交,然后在 github 上进行 pull request 的创建
https://github.com/apache/superset/pull/2136 (Fix werkzeug instance was created twice in Debug Mode (#2135) #2136)

$ git fetch https://github.com/apache/superset.git master:tmp
$ git diff tmp
$ git merge tmp
$ git branch -d tmp

Fetch all tags

1
2
3
4
5
$ git fetch --tags
$ git checkout tags/release-3.4.6
$ git checkout master
Previous HEAD position was 1285c982... ZooKeeper 3.4.6 release.
Switched to branch 'master'

Git Merge

1
2
3
4
5
# 如果不希望 PR 中的 comment 信息被冲掉,可以使用 `git merge` 替代 `git rebase`
$ git merge
# 如果存在冲突,解决后,执行如下两个命令
$ git add .
$ git merge --continue

Git Apply

1
2
# 指定 --reject 强制打补丁,会生成 .rej 文件,需要手动解决冲突
$ git apply --reject yuzhouwan.patch

Git Reflog

恢复 git reset --hard

1
2
3
4
5
6
7
# 找到 reset 操作的
$ git reflog
2a93709d (HEAD -> yuzhouwan, origin/yuzhouwan) HEAD@{0}: reset: moving to 631cc5233063bb014587a9caf0c9e3095fe6a60e
b5b67779 HEAD@{1}: commit: Something important

# 回滚到 reset 操作前的一次提交
$ git reset --hard b5b67779

Git Remote

Change remote url

1
$ git remote set-url origin <url>

Pull specific tag from remote

1
$ git pull origin release-1.7.7:release-1.7.7

同时 push 到多个仓库

1
2
3
4
5
$ git remote set-url --add origin git@github.com:asdf2014/draft.git
$ git remote -v
origin https://git.coding.net/BenedictJin/test.git (fetch)
origin https://git.coding.net/BenedictJin/test.git (push)
origin git@github.com:asdf2014/test.git (push)

删除远程仓库

1
$ git remote rm origin

Git Reset

回退某一个文件的修改

1
$ git reset HEAD^ yuzhouwan.txt

Git Revert

创建某一个 commit 相反的 patch

1
$ git revert <commit number>

Git Rm

清理缓存

描述

 某些已经被加到 .gitignore 的文件提示,ignored, tracked with git

解决

1
2
3
4
5
6
7
8
9
10
11
12
# 单个文件
$ git rm --cached <file>

# 整个项目
$ git rm -r --cached .

# add 变更内容,并切换到 tmp 分支,commit 后,再删除 tmp 分支
$ git add .
$ git checkout -b tmp
$ git commit -m 'Remove ignored files'
$ git checkout master
$ git branch -D tmp

Git Stash

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# 查看当前分支已经存在的改动
$ git status
On branch exception_governance
Your branch is up to date with 'origin/exception_governance'.

Changes to be committed:
(use "git reset HEAD <file>..." to unstage)

new file: a

# 临时保存当前分支的修改
$ git stash
Saved working directory and index state WIP on exception_governance: d5062a04 Govern old error codes and their exceptions

# 查看已经临时保存的改动
$ git stash list
stash@{0}: WIP on exception_governance: d5062a04 Govern old error codes and their exceptions

# 已经看到修改已经被隐藏了
$ git add .
$ git diff --staged

# 再次从 stash 中恢复出之前的修改
$ git stash pop
On branch exception_governance
Your branch is up to date with 'origin/exception_governance'.

Changes to be committed:
(use "git reset HEAD <file>..." to unstage)

new file: a

Dropped refs/stash@{0} (a88e4f6d681eb59b9b22e800f2c00f4c9e22d529)

Git Tag

Create tag

1
2
3
4
5
6
7
8
9
10
11
# 创建简单的标签
$ git tag v0.0.1

# 创建带有附注的 tag
$ git tag -a v0.0.2 -m "v0.0.2"

# 展示 tag 信息
$ git show v0.0.2

# 给指定的 commit,打 tag
$ git tag -a v0.0.3 6d23400

Submit tag

1
2
3
4
$ git push origin v0.0.2

# push 本地所有标签
$ git push origin –tags

Pull with specific tag

1
2
3
4
5
6
7
8
$ git clone

# 列出 tag 列表,并 checkout 到指定的 tag
$ git tag -l
$ git checkout tags/<tag_name>

# checkout 到指定的 tag,并创建一个新的 branch
$ git checkout tags/<tag_name> -b <branch_name>

Delete tag

1
2
3
4
5
6
7
8
# 删除本地 Tag
$ git tag -d v3.4.6.0
Deleted tag 'v3.4.6.0' (was 0e48a03a)

# 删除远程 Tag
$ git push origin :refs/tags/v3.4.6.0
To http://github.com/asdf2014/zookeeper.git
- [deleted] v3.4.6.0

Git 编辑器切换为 Notepad++

1
2
3
4
5
6
7
# 命令行设置
$ git config --global core.editor "'D:/apps/Notepad++/notepad++.exe' -multiInst -notabbar -nosession -noPlugin"

# 修改配置文件
$ vim ~/.gitconfig
[core]
editor = 'D:/apps/Notepad++/notepad++.exe' -multiInst -notabbar -nosession -noPlugin

Git 代理

通过命令设置

1
2
3
4
$ git config --global http.proxy 'http://192.168.1.101:8888'
$ git config --global https.proxy 'https://192.168.1.101:8888'
$ git config --global http.proxy 'socks5://127.0.0.1:1080'
$ git config --global https.proxy 'socks5://127.0.0.1:1080'

通过配置文件设置

1
2
3
4
5
6
7
8
9
$ vim ~/.ssh/config
[http]
proxy = http://192.168.1.101:8888
[https]
proxy = https://192.168.1.101:8888
# [http]
# proxy = socks5://127.0.0.1:1080
# [https]
# proxy = socks5://127.0.0.1:1080

踩过的坑

SSL_ERROR_SYSCALL in connection to git.coding.net:443

描述
1
2
3
4
5
6
7
8
9
10
$ git push origin master
Counting objects: 9, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (9/9), done.
Writing objects: 100% (9/9), 1.05 KiB | 1.05 MiB/s, done.
Total 9 (delta 6), reused 0 (delta 0)
error: RPC failed; curl 35 OpenSSL SSL_connect: SSL_ERROR_SYSCALL in connection to git.coding.net:443
fatal: The remote end hung up unexpectedly
fatal: The remote end hung up unexpectedly
Everything up-to-date
解决
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
# 先确保 git 和 curl 版本不能过低,如果 git <2.60 或者 curl <7.29,则需要升级到最新版本
$ git --version
$ curl --version

# 打开 git 命令的 trace 日志
$ export GIT_CURL_VERBOSE=1
$ export GIT_TRACE_PACKET=2

# 再次执行出错命令
$ git push origin master
// ...
error: RPC failed; curl 7 Failed to connect to 127.0.0.1 port 1080: Connection refused
fatal: The remote end hung up unexpectedly
Everything up-to-date

# 通过日志分析,定位出是 proxy 的问题,关闭 proxy 即可
参考

Git 中文乱码

1
2
3
4
5
6
7
8
9
10
$ git config --global core.quotepath false          # 显示 status 编码
$ git config --global gui.encoding utf-8 # 图形界面编码
$ git config --global i18n.commit.encoding utf-8 # 提交信息编码
$ git config --global i18n.logoutputencoding utf-8 # 输出 log 编码
$ export LESSCHARSET=utf-8 # `git log` 默认使用 `less` 分页,所以需要 `bash` 对 `less` 命令进行 `utf-8` 编码

# 让 `ls` 命令可以显示中文名称
$ vim %GIT_HOME%\mingw64\share\git\completion\git-completion.bash
# 在文件末尾处添加一行
alias ls="ls --show-control-chars --color"

Github 加速

1
2
3
4
5
6
7
8
9
10
11
12
13
14
# Ctrl + R(管理员权限运行)
# notepad "%SystemRoot%\system32\drivers\etc\hosts"

# https://asm.ca.com/zh_cn/ping.php
192.30.253.112 github.com
151.101.56.133 assets-cdn.github.com
192.30.253.116 api.github.com
192.30.253.121 codeload.github.com

# 中国 - 香港特别行政区(hkhkg02)
192.30.253.112 github.com
151.101.100.133 assets-cdn.github.com
192.30.253.116 api.github.com
192.30.253.121 codeload.github.com

Patch

1
2
$ git diff > patch.diff
$ git apply patch.diff

SSH 免密

常规操作

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# 如果没有 .ssh 隐藏文件,则需要先打开 `git bash`,并执行
$ mkdir ~/.ssh
$ chmod 700 ~/.ssh

$ cd ~/.ssh
$ ssh-keygen -t rsa -C "asdf2014@apache.org"

# 将 ~/.ssh/id_rsa.pub 中的公钥加入 github/gitlab
$ ssh -T git@github.com
Hi asdf2014! You've successfully authenticated, but GitHub does not provide shell access. '

# http -> ssh
$ git remote -v
origin https://github.com/asdf2014/yuzhouwan (fetch)
origin https://github.com/asdf2014/yuzhouwan (push)

$ git remote set-url origin git@github.com:asdf2014/yuzhouwan.git

$ git remote -v
origin git@github.com:asdf2014/yuzhouwan.git (fetch)
origin git@github.com:asdf2014/yuzhouwan.git (push)

如何在代理环境下,同时支持 github / gitlab / coding 的免密操作

场景介绍

  • github.comcoding.net 需要走代理访问
  • gitlab 是自建的私服

PAC 配置

 在任何 git 相关操作之前,需要先配置 PAC 文件,来保证本机网络的畅通

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
var domains = {
"coding.net": 1,
"git.coding.net": 1,
"github.com": 1,
"ssh.github.com": 1
};

var proxy = "__PROXY__";

var direct = 'DIRECT;';

var hasOwnProperty = Object.hasOwnProperty;

function FindProxyForURL(url, host) {
var suffix;
var pos = host.lastIndexOf('.');
pos = host.lastIndexOf('.', pos - 1);
while(1) {
if (pos <= 0) {
if (hasOwnProperty.call(domains, host)) {
return proxy;
} else {
return direct;
}
}
suffix = host.substring(pos + 1);
if (hasOwnProperty.call(domains, suffix)) {
return proxy;
}
pos = host.lastIndexOf('.', pos - 1);
}
}

SSH 配置

 在配置 SSH 之前,同样需要保证 ssh 命令使用的网络代理是正确的

 首先,找到 connect 命令安装路径

1
2
3
4
5
$ which connect
/mingw64/bin/connect

$ which connect.exe
/mingw64/bin/connect.exe

 其次,修改 ~/.ssh/config 文件

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
Host github.com
User git
Port 22
Hostname github.com
IdentityFile ~/.ssh/id_rsa # 这里也可以填写绝对路径
TCPKeepAlive yes
IdentitiesOnly yes
ProxyCommand /mingw64/bin/connect.exe -H 127.0.0.1:1080 %h %p

Host ssh.github.com
User git
Port 443
Hostname ssh.github.com
IdentityFile ~/.ssh/id_rsa
TCPKeepAlive yes
IdentitiesOnly yes
ProxyCommand /mingw64/bin/connect.exe -H 127.0.0.1:1080 %h %p

Host git.coding.net
User <email> # coding.net 这里比较特殊,需要填写注册的邮箱地址
PreferredAuthentications publickey
IdentityFile ~/.ssh/id_rsa
TCPKeepAlive yes
IdentitiesOnly yes
ProxyCommand /mingw64/bin/connect.exe -H 127.0.0.1:1080 %h %p

Host yuzhouwan.gitlab.com
User git
Port 22
Hostname yuzhouwan.gitlab.com
IdentityFile ~/.ssh/id_rsa
TCPKeepAlive yes
IdentitiesOnly yes

 然后,生成私钥、公钥,并分别拷贝公钥到 github / gitlab / coding 服务器中,具体操作见上文描述

 最后,验证

1
2
3
4
5
6
7
8
9
$ ssh -T git@github.com
Hi asdf2014! You've successfully authenticated, but GitHub does not provide shell access.

$ ssh -T git@yuzhouwan.gitlab.com
Welcome to GitLab, BenedictJin!

$ ssh -T git@git.coding.net
Coding 提示: Hello BenedictJin, You've connected to Coding.net via SSH. This is a personal key.
BenedictJin,你好,你已经通过 SSH 协议认证 Coding.net 服务,这是一个个人公钥

保持从 fork 端更新代码

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# 申明 fork 端的仓库地址
$ git remote add upstream git@gitlab.yuzhouwan.com:asdf2014/yuzhouwan.git

# check 是否添加正确
$ git remote -v
origin git@gitlab.yuzhouwan.com:asdf2018/yuzhouwan.git (fetch)
origin git@gitlab.yuzhouwan.com:asdf2018/yuzhouwan.git (push)
upstream git@gitlab.yuzhouwan.com:asdf2014/yuzhouwan.git (fetch)
upstream git@gitlab.yuzhouwan.com:asdf2014/yuzhouwan.git (push)

# 更新所有的分支
$ git fetch upstream

# 指定更新某一个分支,这里以 master 分支为例
$ git fetch upstream master

# 使用 fork 端的 master 分支进行 rebase
$ git rebase upstream/master

代码风格配置

1
2
3
4
5
6
7
8
9
10
11
Intellij Idea

# download: http://www.arminalter.com/public/img/attach/checkstyle/eclipse-java-google-style.xml
File - Settings - Editor - Code Style - Schema - Manage - Import - Eclipse XML Profile
File - Settings - Plugins - "CheckStyle-IDEA"

# download: http://www.arminalter.com/public/img/attach/checkstyle/google_checks.xml
File - Setting - Other Settings - Check Style(+) # 如果这里使用的是 带有变量的 xml 文件,需要正确指定对应的 value 值
File - Settings - Editor - Inspections - Checkstyle real-time scan(√) # 开启实时 check code style

# 一般的,项目中都会给出 format.xml 文件,如 hadoop(hadoop-format.xml) / druid(druid_intellij_formatting.xml) etc.

换行符

Auto CRLF

1
2
3
4
5
6
7
8
# 提交时转换为 LF,检出时转换为 CRLF
$ git config --global core.autocrlf true

# 提交时转换为 LF,检出时不转换
$ git config --global core.autocrlf input

# 提交检出均不转换
$ git config --global core.autocrlf false

Safe CRLF

1
2
3
4
5
6
7
8
# 拒绝提交包含混合换行符的文件
$ git config --global core.safecrlf true

# 允许提交包含混合换行符的文件
$ git config --global core.safecrlf false

# 提交包含混合换行符的文件时给出警告
$ git config --global core.safecrlf warn

整合持续集成

Travis

.travis.yml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
language:
- java
- scala
- python
- groovy

os:
- windows

jdk:
- oraclejdk8

scala:
- 2.11.8

python:
- 2.7.12

groovy:
- 2.3.11

before_install: sudo echo "MAVEN_OPTS='-Xmx2048m -Xms1024m -Dorg.slf4j.simpleLogger.defaultLogLevel=error'" > ~/.mavenrc

script:
- mvn clean install -B && mvn clean -B

env:
global:
- MAVEN_OPTS: "-Xmx2048m -Xms1024m -Dorg.slf4j.simpleLogger.defaultLogLevel=error"

sudo: required

cache:
directories:
- $HOME/.m2

效果图

1
[![Build Status](https://travis-ci.org/asdf2014/yuzhouwan.svg?branch=master)](https://travis-ci.org/asdf2014/yuzhouwan)

Build Status

Tips: Full code is here.

设置编辑器

在 Mac 下设置 sublime 作为编辑器

1
2
3
4
5
6
7
# 修改 git 配置文件
$ vim ~/.gitconfig
[core]
editor = /Applications/Sublime\\ Text.app/Contents/SharedSupport/bin/subl -n -w

# 或者通过命令行配置
$ git config --global core.editor "/Applications/Sublime\ Text.app/Contents/SharedSupport/bin/subl -n -w"

GitHub CLI

安装

1
2
$ brew install ghgh version
$ gh version
1
2
gh version 1.0.0 (2020-09-16)
https://github.com/cli/cli/releases/tag/v1.0.0

首次获取 issue 列表时需要进行赋权

1
$ gh issue list
1
2
3
Notice: authentication required
Press Enter to open github.com in your browser...
Authentication complete. Press Enter to continue...

这里以 Apache Druid 为例

获取 issue 列表

1
$ gh issue list
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33

Showing 30 of 928 issues in apache/druid

#10403 Kafka ingestion sometimes produces rows that aren't aggregated (Uncategorized problem report) about 15 hours ago
#10402 Make use of a single instance of Axios in the web-console (Design Review, Proposal) about 16 hours ago
#10395 Getting error when accessing materialized view query in web ... about 3 days ago
#10393 Error while adding a global cached lookup with has header an... (Uncategorized problem report) about 4 days ago
#10384 OutOfMemoryError when hadoop ingest about 3 days ago
#10380 Druid 0.13.0 NPE problem (Uncategorized problem report) about 1 day ago
#10378 Adding Task Slot Count Metrics to Druid Overlord (Area - Metrics/Event Emitting, Design Review, Proposal, …) about 2 days ago
#10375 Upgrade AWS SDK (Feature/Change Description) about 6 days ago
#10369 Using `LIMIT 0` in SQL SELECT query causes `sqlOuterLimit` t... (Area - Querying, Bug) about 9 days ago
#10367 Add missing sqlQueryContext API (Feature/Change Description) about 9 days ago
#10364 Double Sketch Histogram: ReadOnlyException Memory is read on... (Uncategorized problem report) about 10 days ago
#10361 Coordinator fails to create meta tables in PostgreSQL (Uncategorized problem report) about 8 days ago
#10358 Update cassandra-storage extension to use the Datastax java ... (Area - Dependencies, Area - Extension, Security) about 13 days ago
#10352 Metrics reporting system for native parallel batch ingestion (Area - Batch Ingestion, Design Review, Proposal) about 9 days ago
#10349 Druid data loader does not work with input time column name ... (Uncategorized problem report) about 3 days ago
#10348 druid.segmentCache.locationSelectorStrategy config raise Exc... about 10 days ago
#10347 InvalidRequestException(why:You have not logged in),How to ... (Uncategorized problem report) about 14 days ago
#10346 Druid Services on same machine about 15 days ago
#10344 Group By V2 query should use the Query/result level cache, i... (Feature/Change Description) about 15 days ago
#10342 Azure Events Hub tile is enabled when Kafka extension is not... (Bug) about 16 days ago
#10334 The costs of segments that are marked to be dropped in CostB... (Uncategorized problem report) about 18 days ago
#10331 Fresh Docker install results in "Uh... I have no servers. No... (Uncategorized problem report) about 20 days ago
#10329 Add support to show leader coordinator in `Services` web con... (Feature/Change Description) about 21 days ago
#10328 Can we ingest data from multiple hdfs source about 21 days ago
#10326 Extension druid-kafka-extraction-namespace not been loaded about 21 days ago
#10323 Query time out in 1 to 2 minutes, even though timeout specif... (Uncategorized problem report) about 22 days ago
#10322 HttpPostEmitter emit duplicatie failed metrics (Uncategorized problem report) about 23 days ago
#10321 [Proposal] Design for a Configurable Index Type (Design Review, Proposal) about 12 hours ago
#10303 Encrypt Druid Router and Coordinator URL:<Port> about 29 days ago
#10301 Issues with export-metadata (Uncategorized problem report) about 29 days ago

获取 PR 列表

1
$ gh pr list
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33

Showing 30 of 77 pull requests in apache/druid

#10406 Web console: fix lookup edit dialog, allow column renaming implydata:edit-fix
#10405 Document change in results of groupBy queries with subtotalsSpec sthetland:patch-2
#10404 Remove max rows per segment from compaction dialog ccaominh:compaction-dialog-no-max-rows-per-segment
#10401 vectorized expressions and expression virtual columns clintropolis:vectorize-expr
#10400 optimize_getPendingSegmentsForIntervalWithHandle xiangqiao123:optimize_getPendingSegmentsForIntervalWithHandle
#10398 Issue fix for CSV loading with header and skip header not parsing well. tarunparackal:Lookup_load_CSV_TSV_parse_issue
#10396 Update index.md tlblessing:patch-1
#10386 Upgrade AWS SDK mitchlloyd:aws-sdk-upgrade
#10383 [WIP]Fix ingestion failure of pretty-formatted JSON message FrankChen021:json_parse_bug
#10379 Adding task slot count metrics to Druid Overlord mghosh4:add_more_worker_metrics
#10377 Include Sequence-building time in CPU time metric. gianm:cpu-incl-run
#10376 Live reporting system for parallel task jihoonson:live-metrics-system
#10371 Auto-compaction snapshot status API maytasm:IMPLY-1499
#10368 Adding the missing sqlQueryContext api mghosh4:missing_sqlquerycontext_api
#10366 Add caching support to join queries abhishekagarwal87:join_cacheable
#10365 Inject ObjectMapper instead of manually setting it for TaskReportFileWriter jihoonson:inject-mapper-report-writer
#10363 fix injection failure of StorageLocationSelectorStrategy objects FrankChen021:bug_10348
#10362 Fix negative queuedSize problem in CuratorLoadQueuePeon viongpanzi:bug-fix-coordinator-negative-queue-size
#10359 Add shuffle metrics for parallel indexing jihoonson:shuffle-metrics
#10357 [web-console] Update README.md AshishKapoor:patch-1
#10356 Avoid large limits causing int overflow in buffer size checks dylwylie:large-limit-int-overflow
#10339 Security overview documentation sthetland:security-doc-revamp
#10335 [WIP] Design for a Configurable Index Type liran-funaro:config-index
#10330 Allow using jsonpath predicates with AvroFlattener lkm:avro-jsonpath-predicate
#10319 Fix hadoop fs iterator to handle empty terminal directories a2l007:fix_spider
#10314 Add config and header support for confluent schema registry. spinatelli:Druid-8806
#10309 introduce DynamicConfigProvider interface and make kafka consumer props extensible himanshug:kafka_servers
#10298 early exit for getComparator in NumericTopNMetricSpec ArvinZheng:druid-9849
#10291 Upgrade ORC to 1.5.10 version medb:orc_1.5.10
#10290 Upgrade Guava to 28.2-jre version medb:guava_28

切换到某一个 PR 中

1
$ gh pr checkout 10406
1
2
3
From github.com:apache/druid
* [new ref] refs/pull/10406/head -> edit-fix
Switched to branch 'edit-fix'
使用该命令后,会自动下载并切换到 PR 所对应的 branch 中

查看 PR 的 diff 内容

1
$ gh pr diff

合并 PR

1
$ gh pr merge
1
2
3
4
? What merge method would you like to use?  [Use arrows to move, type to filter]
> Create a merge commit
Rebase and merge
Squash and merge

英文缩写

缩写 全拼 含义
ACK Acknowledgement 同意(改变 / 概念)
AFAICT As Far As I Can Tell 据我所知
AFAIK As Far As I Know 据我所知
AKA Also Known As 也称作
ASAP As Soon As Possible 尽快
BTW By The Way 顺便一提
CC Carbon Copy 抄送
FWIW For What It´s Worth 无论如何
FWIAW For What It´s All Worth 不管有没有用(FWIW 含义一样,且 FWIW 更常用一些)
FYI ForYour Information 供你参考
IANAL I Am Not A Lawyer 我不是律师(但是我发现了一个问题)
IIRC If I Recall Correctly 如果我没有记错的话
IMHO In My Humble Opinion 以我浅见
IMO In My Opinion 我的想法是
LGTM Looks Good to Me 在我看来很好
NACK / NAK Negative Acknowledgement 不同意(改变 / 概念)
OTOH On The Other Hand 另一方面
PTAL Please Take a Look 请看一下
RFC Request For Comments 征求意见
SGTM Sounds Good to Me 听起来不错
TBD To Be Done 尚未完成
TBH To Be Honest 老实说
TBR To Be Reviewed 准备被审查
TL;DR Too Long; Didn’t Read 太长懒得看
WDYT What Do You Think? 你怎么看?
WIP Work in Processing 进行中
WTF Why The Face 你懂的

资料

Blog

Doc

Trick

Emoji

欢迎加入我们的技术群,一起交流学习

群名称 群号
人工智能(高级)
人工智能(进阶)
BigData
算法

欢迎关注我的其它发布渠道