向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] //删除本地分支
问题1
git checkout dev报错:
error: 您对下列文件的本地修改将被检出操作覆盖:
source/sections/MGPUSim/debug.md
请在切换分支前提交或贮藏您的修改。
正在终止
解决方案:
git stash
git branch -a
git commit -m ""
git push
问题2
error: 您对下列文件的本地修改将被合并操作覆盖: source/sections/***/debug.md source/sections/***/devOps.md source/sections/***/quickly-start.md
解决方案:
git pull 强制覆盖
git fetch --all
git reset --hard origin/<branch_name>