Python之Web开发中级教程----搭建Git环境三
多人分布式使用仓库操作实例
场景:开发者A,开发者B在同一个项目协同开发,修改同一个代码文件。开发者A在Win10下,开发者B在Ubuntu下。
1、开发者A修改提交代码
从GitHub: Let's build from here · GitHub上获取远程仓库地址:GitHub - zyyhit/gtest: test by go
进入Cmd.exe,进入工作目录,执行git clone https://github.com/zyyhit/gtest.git

问题:
fatal: unable to access 'https://github.com/...':
OpenSSL SSL_read: SSL_ERROR_SYSCALL,errno 0
原因:
一般是因为服务器的SSL证书没有经过第三方机构的签署。
解决方法:
进入cmd,执行以下的命令:
git config --global http.sslVerify false

本地目录如下:

添加一行代码: print(" 开发者 A")

设置开发者 A 的信息
Cmd中执行命令:
进入工作目录
Git config user.name '开发者A'
Git config user.email '开发者A@163.com'

上传到git
- Cmd中执行命令:git commit -am 'A' 添加到仓库区
- Cmd中执行命令:git push 推送到git,在弹出验证的窗口中输入之前生成的token
Tip: git commit -am相当于两步操作合并为一步。即
git add .
git commit -m ' 注释 '

2、开发者B基于开发者A的基础上修改提交代码

chmod a+w hello.py将只读的属性改为可写
tip:
如果遇到权限不够的情况,命令行前加上sudo,即赋予root权限。

在hello.py中添加一句代码:print("developer")
执行命令:
Git status
Git commit -am 'B'
Git push


3、开发者A确认开发者B所做的修改
执行命令:
git pull


执行:git log 可以查看修改记录
