首页 > 解决方案 > How to develop between branches when you have permanent unstaged changes?

问题描述

I have my whole production code in a repository and locally I had to changed some backend/frontend code out of neccessity and leave them in a permanant "unstaged change" mode.

Since I did all the test locally, I didn't need to use branches until today.

We now have a dev branch and I commit my changes to dev then checkout master and git merge dev.

The only issue is that anytime my change happens to one of those unstaged files, I get the famous:

Please commit your changes or stash them before you switch branches.
Aborting

This answer somehow helps https://stackoverflow.com/a/22424970 but this is not an efficient way for me to do this on every commit.

Is there any way I can do less work on each commit/merge?

标签: gitgit-checkout

解决方案


并非所有这些,新的部分都已提交,其余部分保留。

好吧,但那是你的问题。文件是 git 中思想的原子单位。您不能仅将文件的一部分标记为 git 权限之外。如果您向 git 显示任何文件,git 现在知道整个文件并看到(并且正确地说)您已修改。这就是你正在做的事情。

所以,你有相互矛盾的欲望。基本上,如果您要以这种方式工作,那么您必须承受后果。


推荐阅读