git-new-workdir: Commit in working tree A causes bogus changes in tree B

独自空忆成欢 提交于 2019-11-29 12:24:42

I think this is the intended behavior. From http://nuclearsquid.com/writings/git-new-workdir/:

Create a new commit or branch in one of your working directories, they’re instantly available in all working directories.

When you commit a change in A, that commit is available to B as well. Since the line you just added in A isn't in B, it appears that you have made a change since the most recent commit.

I think the purpose of multiple working directories is to have different branches checked out at the same time.

As of 2015, this question is obsolete.

git-new-workdir has been superseded by git worktree (introduced in Git V2.5, July 2015). git worktree solves the problem described in this question by flatly refusing to check out the same branch in two worktrees:

$ git checkout myBranch
fatal: 'myBranch' is already checked out at '/tmp/otherworktree'
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!