Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在使用 Git。我正在处理带有未提交更改的分支-A,我现在不想提交。假设有一个名为 new_file 的文件。我想用分支 B 历史的 new_file 覆盖分支 A 的 new_file(即不是分支 B 上的最新版本的 new_file)
git checkout B~N -- new_file
其中 B 是分支,N 是要返回的分支 B 历史记录中的修订数。
例如:
git checkout B~10 -- new_file
将从分支 B 的历史记录中的 10 个提交中检出 new_file。
或者,如果您只有哈希
git checkout <hash> -- new_file
git checkout 6cdd6ef37 -- new_file