I have a problem with Git for Windows.
我在使用Git for Windows时遇到问题。
I have two branches in one project: master
and membership
. The problem is that, when I modify a file in the membership
branch and switch back to master
, I still have the modification. The membership
branch is a local branch.
我在一个项目中有两个分支:主人和成员。问题是,当我修改成员资格分支中的文件并切换回master时,我仍然有修改。会员分支是本地分支。
If I commit when the master
is the active branch, changes are committed to master. If I push when membership
is the active branch, a remote branch is created for membership
(which is what I want).
如果我在master是活动分支时提交,则更改将提交给master。如果我在成员资格是活动分支时推送,则会为成员资格创建一个远程分支(这就是我想要的)。
I have tried switching branches but it didn't worked.
我试过切换分支但它没有用。
1 个解决方案
#1
2
You still see local modifications after switching branches because Git is not malicious. It does not have seemingly-safe commands that secretly destroy your data. The commands that destroy your data are the commands that you might reasonably expect to destroy your data.
切换分支后仍然会看到本地修改,因为Git不是恶意的。它没有看似安全的命令来秘密破坏你的数据。破坏数据的命令是您可能合理地希望破坏数据的命令。
If you want to completely get rid of local uncommitted modifications, there's a separate command just for that: git reset --hard
. To also get rid of uncommitted newly created directories and files, use git clean -df
.
如果你想彻底摆脱本地未提交的修改,那么就有一个单独的命令:git reset --hard。要删除未提交的新创建的目录和文件,请使用git clean -df。
You can do that before or after you switch branches.
您可以在切换分支之前或之后执行此操作。
If you don't want to get rid of your local uncommitted modifications, if you just don't want them to be part of your new branch, commit or stash them before switching branches.
如果您不想删除本地未提交的修改,如果您只是不希望它们成为新分支的一部分,请在切换分支之前提交或存储它们。
#1
2
You still see local modifications after switching branches because Git is not malicious. It does not have seemingly-safe commands that secretly destroy your data. The commands that destroy your data are the commands that you might reasonably expect to destroy your data.
切换分支后仍然会看到本地修改,因为Git不是恶意的。它没有看似安全的命令来秘密破坏你的数据。破坏数据的命令是您可能合理地希望破坏数据的命令。
If you want to completely get rid of local uncommitted modifications, there's a separate command just for that: git reset --hard
. To also get rid of uncommitted newly created directories and files, use git clean -df
.
如果你想彻底摆脱本地未提交的修改,那么就有一个单独的命令:git reset --hard。要删除未提交的新创建的目录和文件,请使用git clean -df。
You can do that before or after you switch branches.
您可以在切换分支之前或之后执行此操作。
If you don't want to get rid of your local uncommitted modifications, if you just don't want them to be part of your new branch, commit or stash them before switching branches.
如果您不想删除本地未提交的修改,如果您只是不希望它们成为新分支的一部分,请在切换分支之前提交或存储它们。