原始分支提交,分支和撤销是否安全? [英] Is it safe to commit, branch and undo at original branch?
问题描述
在分支A处提交,分支一个新的分支B,在A处撤消最后一个提交(或更多)(重置为前一个提交),将B的历史记录从A中删除是安全的?
b $ b为了阐明你的例子,你现在有这样的例子:
ZYXW < - A
您想要将B分支是,所以你会有这样的:
ZYXW < - A,B
然后将A还原到更早的点
ZY < - A
\
XW < - B
是的,你可以做到这一点。分支只是指向提交的指针,所以你可以将它们移动到周围。只要提交具有指向它的分支,它就会留在您的存储库中供将来使用。
但另一个重要的问题是:A跟踪远程分支的起源/ A?如果是这样,你需要更加小心,不要改变原产地/ A的历史。
It it safe to commit at branch A, branch a new branch B, undo last commit (or more) at A (resetting to a previous commit), leaving B with history that was deleted from A?
To clarify your example, you currently have this:
Z-Y-X-W <--A
And you'd like to branch B where A currently is, so you'll have this:
Z-Y-X-W <--A,B
And then revert A to an earlier point
Z-Y <--A
\
X-W <--B
Yes, you can do this. Branches are just pointers to a commit, so you can move them around willy nilly. As long as a commit has a branch pointing to it, it will stay in your repository for future use. Remove the last brach pointing to it, and it will be garbage collected.
But another important question: is A tracking a remote branch origin/A? If so, you need to be much more careful not to alter the history of origin/A.
这篇关于原始分支提交,分支和撤销是否安全?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!