尽管没有差异,Git不会让rebase

时间:2016-01-13 06:07:38

标签: git version-control

不知道是怎么回事,但今天早上我尝试重新定义我的代码库,.gitmodules不会让这种情况发生

终端转储:

~/codebase > git pull --rebase origin master
From https://gitlab.site.com/site/site
 * branch            master     -> FETCH_HEAD
First, rewinding head to replay your work on top of it...
error: Your local changes to the following files would be overwritten by checkout:
    .gitmodules
Please, commit your changes or stash them before you can switch branches.
Aborting
could not detach HEAD

~/codebase > git status
On branch master
Your branch is behind 'origin/master' by 75 commits, and can be fast-forwarded.
  (use "git pull" to update your local branch)
Untracked files:
  (use "git add <file>..." to include in what will be committed)

    .DS_Store
    _test_certs/
    db_dump.sql
    dump.rdb
    local.py
    nohup.out


nothing added to commit but untracked files present (use "git add" to track)

diff也不会显示任何差异:

~/codebase > git diff
~/codebase >

即使尝试了update-index --assume-unchanged,但仍然无效:

~/codebase > git update-index --assume-unchanged .gitmodules
~/codebase > git pull --rebase origin master
From https://gitlab.site.com/site/site
 * branch            master     -> FETCH_HEAD
First, rewinding head to replay your work on top of it...
error: Your local changes to the following files would be overwritten by checkout:
    .gitmodules
Please, commit your changes or stash them before you can switch branches.
Aborting
could not detach HEAD

~/codebase > git checkout master .gitmodules
error: pathspec '.gitmodules' did not match any file(s) known to git.

我尝试从.gitmodules查看master,甚至是HARD reset ..没有用......而且因为这个文件也在主文件中,所以我不能改变它...如此循环的问题......

1 个答案:

答案 0 :(得分:1)

尝试使用:

git rm --cached -r .
git reset --hard

第一个命令将删除工作索引中的所有文件,包括麻烦的.gitmodules文件。第二个命令将重置分支的尖端以指向该分支的当前HEAD

GitHub的文档有一个extremely valuable article来处理你的情况。