【发布时间】:2012-03-22 01:54:08
【问题描述】:
我一直在使用 git --assume-unchanged yacs/settings/development.py 来忽略我的 dev 分支中的本地数据库配置文件。但是当我想切换分支(用于部署)时,我得到一个错误,我仍然有未决的更改:
% git checkout production
error: Your local changes to the following files would be overwritten by checkout:
yacs/settings/development.py
Please, commit your changes or stash them before you can switch branches.
Aborting
这很烦人。我知道如何解决这个问题的唯一方法就是把它藏起来:
% git stash
% git checkout production
% git merge dev
% ./deploy.sh
% git checkout dev
% git stash pop
# On branch dev
# 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: yacs/settings/development.py
#
但现在它又回到了索引中(呃)!这个工作流程有更好的替代方案吗?
[我并不特别关心本地更改是否保留在本地(也就是说,如果它是生产分支就可以了),我只是不希望它被推送到远程存储库。]
【问题讨论】:
-
这对我不起作用。我用 --skip-worktree 添加文件,但 git status 没有显示。但是,我仍然无法切换到另一个分支。我错过了什么?
标签: git