Git

Instructions

更新远程分支列表

git fetch --all

仓库的分支已删除,而本地尚留存 remotes/origin/**,执行下述命令进行清理。

1
git remote update origin --prune

Git switch tags

1
git checkout [origin] tags/v1.0

Git using proxy

1
2
3
4
5
6
# http(s).proxy
git config --global http.proxy http://proxy.example.com:8080
git config --global https.proxy https://proxy.example.com:8080

# socks proxy
git config --global socks.proxy socks5://proxy.example.com:1080

SSH-KEYGEN

1
2
3
4
5
6
# -t specifies the algorithm
# -b specifies the buffer size
ssh-keygen -t rsa -b 2048

# ed25519
ssh-keygen -t ed25519 -b 4096 -f cloudcone-sshkey
1
2
+ PermitRootLogin yes # 允许root登录
+ PubkeyAuthentication yes # 允许通过公钥验证用户

Recall a git merge

git merge --abort

multiply identities management

  • ~/.gitconfig
  • ~/.gitconfig-work
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
# ~/.gitconfig
## git alias -> git ac
[alias]
  cg = !git config --global -e
  ac = !git add . && git commit

[user]
    # name = work-identity
    # email = [email protected]

[includeIf "gitdir:~/github/"]
    path = ~/.gitconfig-github

# ~/.gitconfig-github
[user]
    name = github
    signingkey = aaaa
    email = [email protected]

[commit]
    gpgsign = true

References

Licensed under CC BY-NC-SA 4.0
Get Things Done
Built with Hugo
Theme Stack designed by Jimmy