赞
踩
login.py
文件代码cd E:\downloads\study\FL_code\GitStudy\zhangsan\info
num1 = 10
git commit -am '第一个变量'
推送到远程仓库:git push
新增代码
遇到的问题:执行git push时弹出以下对话框
解决:connect to github中personal access token生成token方法
执行成功
login.py
文件代码cd E:\downloads\study\FL_code\GitStudy\manager\info
git pull
num2 = 20
git commit -am '第二个变量'
推送到远程仓库:git push
本次可以把num2
同步到张三的本地仓库
1.5 按照以上2-3-4
步骤循环操作,即可实现基本的协同开发
git pull
git commit -am '版本描述'
git push
pull
,编辑完再commit
,最后推送是push
login.py
文件代码cd E:\downloads\study\FL_code\GitStudy\zhangsan\info
git pull
num3 = 30
git commit -am '第三个变量'
git push
张三本地仓库和远程仓库代码如下:
login.py
文件代码cd E:\downloads\study\FL_code\GitStudy\manager\info
num3 = 30
git commit -am '第三个变量'
git push
以上操作会出现代码冲突
提示需要先pull
解决完冲突代码后,依然需要add
、commit
、push
提示:如果张三执行pull
没有影响,就算真正解决了冲突代码
容易冲突的操作方式
减少冲突的操作方式
pull
在修改,修改完立即commit
和push
作用:
备份大版本代码
master分支:v1.0→v2.0→...
1.进入到经理的本地仓库info
cd E:\downloads\study\FL_code\GitStudy\manager\info
2.经理在本地打标签
- git tag -a 标签名 -m '标签描述'
- 例:
- git tag -a v1.0 -m 'version1.0'
3.经理推送标签到远程仓库
- git push origin 标签名
- 例:
- git push origin v1.0
补充:删除本地和远程标签
- # 删除本地标签
- git tag -d 标签名
- # 删除远程仓库标签
- git push origin --delete tag 标签名
对比:操作分支前的代码
4.1进入到经理的本地仓库info :cd E:\downloads\study\FL_code\GitStudy\manager\info
没有创建其他分支时,只有(master)main分支
git checkout -b dev
git push -u origin dev
add
、commit
、push
num4
7.1 先切换到master分支
git checkout main
7.2 dev分支合并到master分支
git merge dev
7.3 经理推送合并分支操作到远程仓库
合并分支默认在本地完成,合并后直接推送即可
git push
8.张三同步经理合并后的num4
只有当张三同步代码成功,分支合并才算成功
- cd E:\downloads\study\FL_code\GitStudy\zhangsan\info
- git pull
学习导航:http://www.xqnav.top
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。