这篇文描述的是使用我注册的第二个Github账号对netops_v2.0_beta
仓库进行一次pull requests
计划是修改代码使其在Ubuntu环境也能正常运行,然后推送分支进行pull requests
登陆Github
先fork原仓库至第二个账号(过程略),获取 Clone 链接 https://github.com/weeaster/netops_v2.0_beta.git ,克隆至本地
kir@kir:~/my_repo/netops_v2.0_branch$ git clone https://github.com/weeaster/netops_v2.0_beta.git
Cloning into 'netops_v2.0_beta'...
remote: Enumerating objects: 67, done.
remote: Counting objects: 100% (67/67), done.
remote: Compressing objects: 100% (49/49), done.
remote: Total 67 (delta 32), reused 51 (delta 18), pack-reused 0
Receiving objects: 100% (67/67), 42.97 KiB | 31.00 KiB/s, done.
Resolving deltas: 100% (32/32), done.
kir@kir:~/my_repo/netops_v2.0_branch$
修改代码
- 不是重点
- 主要内容是修改 msoffcrypto 替换 pywin32 库(原仓库已修改),修改系统的路径(左右斜杠符号)
Ubuntu本地Git
本地
git config
配置(免密操作git push)$ git config --global user.name yourusername $ git config --global user.email yourmail@nb.com $ git config --list user.name=username user.email=yourmail@nb.com core.repositoryformatversion=0 core.filemode=true core.bare=false core.logallrefupdates=true remote.origin.url=https://github.com/weeaster/netops_v2.0_beta.git remote.origin.fetch=+refs/heads/*:refs/remotes/origin/* branch.main.remote=origin branch.main.merge=refs/heads/main
cd命令进入本地代码目录,执行
git init
,提示重新初始化现有Git存储库(那么智能)$ git init Reinitialized existing Git repository in /home/kir/my_repo/netops_v2.0_branch/netops_v2.0_beta/.git/
本地创建ssh-key(生成公钥和私钥)
kir@kir:~/$ ssh-keygen -t ed25519 -C "yourmail@nb.com" Generating public/private ed25519 key pair. Enter file in which to save the key (/home/kir/.ssh/id_ed25519): Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /home/kir/.ssh/id_ed25519 Your public key has been saved in /home/kir/.ssh/id_ed25519.pub The key fingerprint is: SHA256:xxxxxx The key's randomart image is: +--[ED25519 256]--+ …… …… +----[SHA256]-----+
Github网站添加SSH keys(基操)
测试
kir@kir:~/my_repo/netops_v2.0_branch/netops_v2.0_beta$ ssh -T git@github.com The authenticity of host 'github.com (20.205.243.166)' can't be established. ED25519 key fingerprint is SHA256:xxxxxx This key is not known by any other names Are you sure you want to continue connecting (yes/no/[fingerprint])? yes Warning: Permanently added 'github.com' (ED25519) to the list of known hosts. Hi weeaster! You've successfully authenticated, but GitHub does not provide shell access.
设置远程仓库地址(https//xxxx不好使,换成git@xxxx)
$ git remote rm origin $ git remote add origin git@github.com:weeaster/netops_v2.0_beta.git $ git remote -v origin git@github.com:weeaster/netops_v2.0_beta.git (fetch) origin git@github.com:weeaster/netops_v2.0_beta.git (push)
三板斧
git add
,git commit
,git push
,推送到ubuntu-branch分支$ git checkout -b ubuntu-branch $ git add . $ git commit -m "ubuntu-branch push" $ git push origin ubuntu-branch
第7步中可能出现的插曲,原因是在github设置了
Keep my email addresses private
,处理步骤如下回显错误提示
$ git push origin ubuntu-branch Enumerating objects: 25, done. Counting objects: 100% (25/25), done. Delta compression using up to 4 threads Compressing objects: 100% (13/13), done. Writing objects: 100% (13/13), 1.60 KiB | 327.00 KiB/s, done. Total 13 (delta 8), reused 0 (delta 0), pack-reused 0 remote: Resolving deltas: 100% (8/8), completed with 8 local objects. remote: error: GH007: Your push would publish a private email address. remote: You can make your email public or disable this protection by visiting: remote: http://github.com/settings/emails To github.com:weeaster/netops_v2.0_beta.git ! [remote rejected] ubuntu-branch -> ubuntu-branch (push declined due to email privacy restrictions) error: failed to push some refs to 'github.com:weeaster/netops_v2.0_beta.git'
在github网站:http://github.com/settings/emails 的
keep my Email private
选项下的找到匿名 Email; 格式是:id+username@users.noreply.github.com重新设置git用户
$git config --global user.email "id+username@users.noreply.github.com"
重置上次commit提交的作者信息
$ git commit --amend --reset-author
再次push
$ git push origin ubuntu-branch
Compare&pull request
切换到 ubuntu-branch 分支,点击 Compare & pull request
按钮
填写信息
原仓库账号处理pull requests
查看pull requests
拒绝该次pull requests
原仓库账号创建分支
提交pull request 的账号重新本地push到一个新分支;重复Compare&pull request步骤,提交pull request时注意选择原仓库创建的分支
同意合并
检查
打开Comparing
查看lib/comm.py
部分代码,可以看到路径的斜杠符号是左斜杠/
最后
- 知乎有个图画挺好,我画一下
- 总体来说还行
- 我不是搞软件的,这么一搞也就图一乐
- 拜了个拜
- 这篇文,不那么欢迎“
来电”来函探讨