@[TOC]Git中Your branch is ahead of ‘origin/master’ by x commits的解决办法
问题描述:新的全局用户名下,修改原有本地库的代码,上传时遇见的问题
在Github中修改了用户名,然后在git中重新社设置全局用户名 ```bash git config --global user.name "new username" ``` 然后修改原有的本地库代,可以通过命令git add test.txt
提交到暂存区里,但是提交到本地库的时候会报错
想通过上传,也报错。
解决方案:
方法一:(保留代码)
git push origin
方法二:(不保留代码)
git reset --hard origin/$branch
方法三:
git fetch origin
方法四:(有没被commit或者push的文件)
git pull --rebase