git 结帐 <branch> -- path/to/file 不工作
git checkout <branch> -- path/to/file not working
当我尝试用 master 分支中的版本替换分支中的文件时,它就好像可以正常工作一样;但是,该文件没有被替换,也没有任何新内容上演。例如,这是一个示例工作流程:
git checkout someBranch
git checkout master -- path/to/file
第二个命令将return就好像没有出错或什么事都没发生一样。如何将不同分支的文件检出到当前分支?
尝试指定提交 ID 而不是分支名称。
来自手册页:
git checkout [-p|--patch] [<tree-ish>] [--] <pathspec>...
When or --patch are given, git checkout does not switch
branches. It updates the named paths in the working tree from the
index and file or from a named <tree-ish> (most often a commit). In
this case, the -b and --track options are meaningless; giving either of
them results in an error. The <tree-ish> argument can be used to
specify a specific tree-ish (i.e. commit, tag or tree) to update the
index for the given paths before updating the working tree.
当我尝试用 master 分支中的版本替换分支中的文件时,它就好像可以正常工作一样;但是,该文件没有被替换,也没有任何新内容上演。例如,这是一个示例工作流程:
git checkout someBranch
git checkout master -- path/to/file
第二个命令将return就好像没有出错或什么事都没发生一样。如何将不同分支的文件检出到当前分支?
尝试指定提交 ID 而不是分支名称。
来自手册页:
git checkout [-p|--patch] [<tree-ish>] [--] <pathspec>...
When or --patch are given, git checkout does not switch branches. It updates the named paths in the working tree from the index and file or from a named <tree-ish> (most often a commit). In this case, the -b and --track options are meaningless; giving either of them results in an error. The <tree-ish> argument can be used to specify a specific tree-ish (i.e. commit, tag or tree) to update the index for the given paths before updating the working tree.