git只从一个分支中删除文件

git只从一个分支中删除文件

本文介绍了git只从一个分支中删除文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我从一个分支中删除文件时,它从所有分支中删除。我可以做什么?

解决方案

使用git删除文件并保持项目状态时( git commit )它只会在该提交及其子代(说:在该分支中)中被删除。当将该分支合并到另一个分支时,它很可能会被删除(除非在其他分支中进行了更改)。



删除文件时,没有提交它然后切换分支,git会将你当前的一组修改应用到另一个分支,在你的情况下删除那个文件。提交删除应该避免你看到的问题

when I delete files from one branch it deletes from all branches. what can I do?

解决方案

when deleting a file with git and persisting that project state (git commit) it will only be deleted in that commit and its children (speaking: in that branch). when merging that branch into another branch it might well be possible, that the file is going to be deleted (unless changed in the other branch).

when deleting a file, not committing it and then switching branches, git will apply your current set of changes to the other branch, in your case deleting the file there too. committing the delete should avoid the issue you are seeing

这篇关于git只从一个分支中删除文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-28 07:22