向github提交代码时,执行" git push -u origin main",提示:
Everything up-to-date
Branch ‘main’ set up to track remote branch ‘main’ from ‘origin’.
解决
1.创建一个新的分支
git branch other //创建新分支other
2.将改动提交到暂存区
git add .
3.提交到版本库
git commit -m "描述内容"
4.提交到远程仓库
git push origin other
5.切换到主分支
git checkout main //github新建仓分支有master改为了main
6.将新建分支合入到主分支上
git merge other
7.提交到远程仓库
git push -u origin main
提交成功
8.提交后本地和远程都出现了新分支,删除此无用分支
git branch -d [branchname] //删除本地分支
远程仓显示多了一个分支"other",删除此无用分支
git push origin -d [branchname] //删除远程分支
再次查看,远程分支已被删除
本地与远程仓库恢复干净。