简体   繁体   English

如何将所有文件和文件夹从一个分支替换/复制到GIT中的另一个现有分支

[英]How Can I replace/copy all file and folder from one branch to another existing branch in GIT

I have 3 branch -> Master , develop and admit_card . 我有3个分支-> Masterdevelopadmit_card I had created before admit_card from the develop branch. 我是在develop分支的admit_card之前创建的。 I always made changes on admit_card branch and merge it into develop . 我一直在做改变admit_card分支并将其合并到develop

But suddenly I have changed some more files and also deleted folder form the develop branch. 但是突然之间,我更改了一些文件,还从develop分支中删除了文件夹。 And now I want to copy/keep updated to the admit_card branch like develop branch (By deleting folders and files). 现在我想复制/保持更新到admit_card像分支develop分支(通过删除文件夹和文件)。

I merged it with develop branch. 我将其与develop分支合并。 It is merging with develop branch properly. 它正在正确地与develop分支合并。 But the issue is the folders and files I deleted from the develop branch is still showing into the admit_card branch. 但是问题是我从develop分支删除的文件夹和文件仍然显示在admit_card分支中。

here is the merge develop branch with admit_card branch. 这是带有admit_card分支的合并开发分支。

git checkout admit_card
git merge develop

what should I do please? 我该怎么办? How can I copy/replace exact develop branch to admit_card branch? 如何将确切的develop分支复制/替换为admit_card分支? Can anybody please help me? 有人可以帮我吗?

Thank you 谢谢

I think rebase is better approach here. 我认为在此重新设置rebase是更好的方法。

On your admit_card branch run 在您的admit_card分支上运行

git rebase develop

This will, in effect, set your admit_card branch to the contents of the develop branch and then play back any additional commits on the admit_card branch on top of this. 这实际上将设置你的admit_card分支的内容develop分支,然后回放任何额外提交的admit_card分支在此之上。 You might have merge conflicts if you have touched the same files in both the branches. 如果您在两个分支中都触摸了相同的文件,则可能会有合并冲突。 Once you resolve the merge conflicts, your admit_card branch will be a clean topic branch on top of your develop branch again. 解决合并冲突后,您的admit_card分支将再次成为位于develop分支顶部的干净主题分支。

Run git rebase --abort if you get stuck with the merge to revert back to how things were. 如果遇到合并问题,请运行git rebase --abort以恢复到原来的状态。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何将一个分支中的特定文件合并到Git中的另一个分支中 - How can I merge a specific file from one branch into another branch in Git Git钩子-如何将文件从一个文件夹复制到同一git分支内的另一个文件夹 - Git hooks - How to copy files from one folder to another folder within same git branch 如何使用 git 将文件从一个分支复制到另一个分支? - How can I copy files from a branch to another using git? 如何将单个文件的版本从一个 Git 分支复制到另一个? - How do I copy a version of a single file from one Git branch to another? 如何将提交从一个分支复制到另一个分支? - How can I copy commits from one branch to another? 如何将更改从一个功能分支复制到从 GIT 中的同一父分支派生的另一个功能分支 - How to copy changes from one feature branch to another feature branch derived from same parent branch in GIT Git将文件夹从主分支复制到另一个分支 - Git Copy a folder from master branch to another branch Git 将文件从现有分支删除到另一个现有分支 - Git remove a file from existing branch to another existing branch 在git中将更改从一个分支更改为另一个分支,以及如何在自己的分支上工作 - Get changes from one branch into another one in git and how can I work on my own branch GIT:如何从一个分支还原一个分支的所有更改 - GIT: How Do I Revert All The Changes Of One Branch From Another Branch
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM