也许最简单的方法是存储当前的更改,检查然后弹出存储。像这样,
git stash
git status
git stash pop
这不适用于所有更改,例如新文件(因为git stash
不会存储它们)。但是,我不得不说我没有重现您的问题:
ebg@taiyo(14)$ git status
# On branch master
# Your branch is ahead of 'origin/master' by 1 commit.
#
nothing to commit (working directory clean)
ebg@taiyo(15)$ ed .gitignore
1165
...
q
ebg@taiyo(16)$ git status
# On branch master
# Your branch is ahead of 'origin/master' by 1 commit.
#
# 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: .gitignore
#
no changes added to commit (use "git add" and/or "git commit -a")
在上面,相对的状态origin
仍然出现。尽管如此,我的建议仍然有效:
ebg@taiyo(17)$ git stash
Saved working directory and index state WIP on master: b541ae8 Ignore 'SPOT Lang*' files
HEAD is now at b541ae8 Ignore 'SPOT Lang*' files
ebg@taiyo(18)$ git status
# On branch master
# Your branch is ahead of 'origin/master' by 1 commit.
#
nothing to commit (working directory clean)
ebg@taiyo(19)$ git stash pop
# On branch master
# Your branch is ahead of 'origin/master' by 1 commit.
#
# 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: .gitignore
#
no changes added to commit (use "git add" and/or "git commit -a")
Dropped refs/stash@{0} (8ff02f7a27053ca7680b0a98048542fcbe2bb440)