SourceTree的使用方法记录,目前的情况是如果我直接在SourceTree软件内使用commit输入框或者拉取按钮时会出现超前和滞后的问题,所以工作中我只将SourceTree只作为可视化工具,选好需要文件后,git的操作代码都在VSCode的终端进行填写。
VSCode 更新项目
更新项目需要固定输入的3个语句:
git stash // 1.暂存目前代码
git pull // 2.拉取更新远程代码
git stash pop // 3.推出第1步暂存的代码(如果有文件与远程文件冲突,这时会看见提示)
在VScode终端中的截图

SourceTree 选择提交文件



VSCode 提交项目
推送项目需要固定输入的3个语句:
git status // 1.查看一下准备推送的文件是否正确
git commit -m 'your notice...' // 2.填写备注信息
git push // 3.提交更新

【其他常用命令】
// 查看当前branch与远程分支关联情况
git branch -vv
// 查看所有分支
git branch --all
// 创建本地分支, 将本地更改推送到远程仓库(创建远程分支)
git checkout -b new-feature
git push -u origin new-feature
// 拉取对应分支并与该远程分支关联
git checkout -b name origin/name
// 撤销最近一次提交但保留更改(超前版本时候可以使用)
git reset HEAD~1
【建议】最好是半天或者做完某个功能就pull push一下,如果:
1.文件冲突需要merge,那手动处理完记得在未暂存文件处对它打勾再提交
2.如果版本超前或滞后(可能提交的时候和别人撞时间了),可以手动把刚刚写的文件复制一份到外部文件夹中,然后reset到当前正确的远程分支里重新提交,有备无患,也可以问下通义千问