git

更新日期: 2016-05-25 阅读次数: 7969 分类: Git

对远端分支进行回滚

git pull origin master
git reset --hard <commit_id>
git push origin master --force

参考 git 怎样删除远程仓库的某次错误提交?

版本号控制

当看到 Facebook Messenger 的版本号已经到了 70.0 的时候,我就明白了,版本号自己开心就好。

Bitbucket 拉取代码报错 Permission denied (publickey)

通过诊断发现

$ ssh -vT hg@bitbucket.org
OpenSSH_7.2p2 Ubuntu-4, OpenSSL 1.0.2g-fips  1 Mar 2016
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug1: Connecting to bitbucket.org [104.192.143.3] port 22.
debug1: Connection established.
debug1: identity file /home/zhongwei/.ssh/id_dsa type 2
debug1: key_load_public: No such file or directory
debug1: identity file /home/zhongwei/.ssh/id_dsa-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_7.2p2 Ubuntu-4
debug1: Remote protocol version 2.0, remote software version OpenSSH_6.4
debug1: match: OpenSSH_6.4 pat OpenSSH* compat 0x04000000
debug1: Authenticating to bitbucket.org:22 as 'hg'
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: algorithm: ecdh-sha2-nistp256
debug1: kex: host key algorithm: ssh-rsa
debug1: kex: server->client cipher: aes128-ctr MAC: umac-64-etm@openssh.com compression: none
debug1: kex: client->server cipher: aes128-ctr MAC: umac-64-etm@openssh.com compression: none
debug1: sending SSH2_MSG_KEX_ECDH_INIT
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: Server host key: ssh-rsa SHA256:zzXQOXSRBEiUtuE8AikJYKwbHaxvSc0ojez9YXaGp1A
debug1: Host 'bitbucket.org' is known and matches the RSA host key.
debug1: Found key in /home/zhongwei/.ssh/known_hosts:1
debug1: rekey after 4294967296 blocks
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: rekey after 4294967296 blocks
debug1: SSH2_MSG_NEWKEYS received
debug1: Skipping ssh-dss key /home/zhongwei/.ssh/id_dsa - not in PubkeyAcceptedKeyTypes
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: No more authentication methods to try.
Permission denied (publickey).

原来问题出在 key 的类型上

It appears OpenSSH 7.0 disables DSA SSH keys by default.

我之前一直习惯生成 dsa 的 key。只需要删掉 key, 然后重新使用 ssh-keygen 生成 rsa 的 key 就可以了。

参考 DSA SSH keys not in PubkeyAcceptedKeyTypes

Pull Request 强制 code review

Git工作流指南:Pull Request工作流

关于作者 🌱

我是来自山东烟台的一名开发者,有敢兴趣的话题,或者软件开发需求,欢迎加微信 zhongwei 聊聊, 查看更多联系方式