git remove files from only one branch

匆匆过客 提交于 2019-12-03 22:35:15

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

No, it is not true. I think your confusion comes from switching between the branches. when you do "git checkout " it preserves your working tree so files you just deleted dont reappear after switching. It is possible to switch to different branch and reset all the changes you have done (you delete files). you can do this by for example writing ""git reset --hard" after switching.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!