git 提交出现error: Your local changes to the following files would be overwritten by checkout

简介:

在提交代码时,直接在master分支push了,而原来的testdemo分支没有merge,这样提交过后会报错

error: Your local changes to the following files would be overwritten by checkout:
        app/Http/Controllers/UsersController.php
Please commit your changes or stash them before you switch branches.
Aborting

提示的是当前改变文件会被覆盖,出现这个问题,我们需要让master回退到上一个版本

git reset --hard 版本号

此时,在使用git merge testdemo分支即可。

git merge testdemo

合并完testdemo分支后,我们再次push即可。

git push
目录
相关文章
|
4月前
|
开发工具 git
git checkout (branchname
git checkout (branchname) 是 Git 中切换分支的一种命令。通过这个命令,你可以将当前工作目录切换到指定的分支上。branchname 参数是可选的,如果不指定,则默认切换到主分支(master 或 main)。
95 2
|
4月前
|
开发工具 git 开发者
|
4月前
|
开发工具 git
Git -- 代码上传错误 error: failed to push some refs to ‘git@gitee.com:JMFive/uni-shop2.git‘
Git -- 代码上传错误 error: failed to push some refs to ‘git@gitee.com:JMFive/uni-shop2.git‘
|
3月前
|
开发工具 git
【已解决】error: failed to push some refs to ‘git@github.com:BATdalao/Github-green.git‘
【已解决】error: failed to push some refs to ‘git@github.com:BATdalao/Github-green.git‘
62 1
|
3月前
|
开发工具 git
git error 已解决【Another git process seems to be running in this repository, e.g. an editor opened by】
git error 已解决【Another git process seems to be running in this repository, e.g. an editor opened by】
46 2
|
3月前
|
开发工具 git
出现“error: failed to push some refs to ‘https://github.com/****.git‘”,如何解决问题
出现“error: failed to push some refs to ‘https://github.com/****.git‘”,如何解决问题
161 1
|
4月前
|
缓存 开发工具 git
Git Cloning into :error: RPC failed
Git Cloning into :error: RPC failed
69 0
|
4月前
|
开发工具 git
If you are using the git profile, you need to set a Git URI in your configuration. If you are using
If you are using the git profile, you need to set a Git URI in your configuration. If you are using
107 0
|
1月前
|
存储 开发工具 git
|
30天前
|
开发工具 git
【GIT 第二篇章】GIT常用命令
Git常用命令涵盖初始化、状态管理、提交、分支处理、远程操作等关键流程。`git init`启动本地仓库,`git clone`下载远程仓库。通过`git status`和`git diff`检查工作状态与差异。利用`git add`暂存文件,`git commit`保存更改。借助`git branch`、`git checkout`、`git merge`和`git rebase`管理分支。使用`git fetch`、`git pull`和`git push`同步远程仓库。通过`git reset`、`git revert`和`git checkout`实现版本回退。
48 0