常见git指令
git status
git branch
git branch -a //查看所有分支(本地+远程)
git stash list
git checkout main
git checkout -b newBranch
git add .
git commit
git stash
git stash pop
git pull
git push
提交代码一条龙:
1.git pull //养成好习惯,提交之前先拉取,合并冲突,避免提交后覆盖别人的代码
2.git status //查看当前修改的文件
3.git add . //修改内容加入暂存区
4.git commit -m"" //暂存区文件提交至本地仓库
5.git push //文件提交至远程仓库
VSCode报错解决
(1)pull代码报代码冲突,【error: Your local changes to the following files would be overwritten by merge】
原因:一般是别人改动提交的代码,然后你本地改了同一个文件,会存在代码冲突
通过git stash —- 通常用这种方法
git stash //暂存修改
git pull //拉取最新代码
git stash pop //恢复暂存修改
//找到冲突文件进行手动合并,合并完正常提交即可