标题: 全网多种方法办理Updates were rejected because the remote contains work [打印本页] 作者: 梦见你的名字 时间: 2024-9-8 17:08 标题: 全网多种方法办理Updates were rejected because the remote contains work 1. 复现错误
本日利用git status查看文件状态,发现有一个文件未提交,如下代码所示:
D:\project\test>git status
On branch master
Your branch is up to date with 'origin/master'.
Untracked files:
(use "git add <file>..." to include in what will be committed)
src/main/java/xxx/po/test.java
nothing added to commit but untracked files present (use "git add" to track)
warning: HTTPS connections may not be secure. See https://aka.ms/gcmcore-tlsverify for more information.
To https:xxx/test.git
! [rejected] master -> master (fetch first)
error: failed to push some refs to 'https:xxx/test.git'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
复制代码
即Updates were rejected because the remote contains work that you do not have locally。
2. 分析错误
Updates were rejected because the remote contains work that you do not have locally翻译成中文就是更新被拒绝,因为远程包含您当地没有的工作。
换句话说,我们想把本身当地的某个项目,关联到远程堆栈并推送上去,但为什么报这个错误呢?
原来,我们在创建堆栈时,都会勾选利用Reamdme文件初始化这个堆栈这个操纵,初始了一个README文件,并配置添加了忽略文件: