【发布时间】:2018-11-22 09:36:24
【问题描述】:
我通过 git status 得到这个:
git status
On branch master
Your branch and 'origin/master' have diverged,
and have 3 and 1 different commits each, respectively.
(use "git pull" to merge the remote branch into yours)
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)
modified: application/models/Usuario_model.php
modified: application/views/Autor/listar.php
modified: application/views/Libro/modificar.php
modified: application/views/Libro/perfil.php
modified: application/views/ListaLibros/listar.php
modified: application/views/Valoracion/crearOk.php
no changes added to commit (use "git add" and/or "git commit -a")
git add <file> 什么都不做
git pull 产生这个:
git pull
: Your local changes to the following files would be overwritten by merge:
application/models/Usuario_model.php
application/views/Autor/listar.php
application/views/Libro/perfil.php
application/views/ListaLibros/listar.php
application/views/Valoracion/crearOk.php
commit your changes or stash them before you merge.
Aborting
我无法推送,因为“我当前分支的尖端位于其远程对应分支之后”。
所以我不能先推再拉,我不能先拉再提交,我也不能提交,因为我无法暂存更改。
发生了什么,我该如何解决?
【问题讨论】:
-
你可以在执行
git commit -m "Your Message"之前尝试git add *。 -
运行
git add application然后git status会发生什么?这两个命令之后的输出是什么? -
@Code-Apprentice 在
git add application和git status显示之前的一切之后什么都没有发生 -
这很奇怪。检查您的
.gitignore文件以查看是否有任何规则与这些文件匹配。确保您位于正确的目录中。最后,如果所有其他方法都失败了,您可以按照我的回答中所述使用git stash来拉取更改。不幸的是,无论如何,您仍然必须解决提交更改的问题。
标签: git github push commit pull