I am a novice to GIT. I have created a new branch as b1 and raised one pull request in it. I want to copy this branch as b2. I referred command to copy branch here How can I copy the content of a branch to a new local branch? If I am able to copy the branch, then How to keep PR and commit histories also in branch b2. Thanks a million.
Asked
Active
Viewed 118 times
0
-
By raise a pull request, do you mean that you have a pull request from another branch into b1 or a pull request from b1 to another branch? – TheArcticWalrus Feb 07 '20 at 15:29
-
I don't know what you mean by "keep commit history", since both branches will have the exact same. For the pull request, you'll have to recreate one with `b2` (and delete/decline the `b1` one) – Romain Valeri Feb 07 '20 at 15:32
-
@RomainValeri thanks for ur reply :). pull request or pr in the branch b1 already available. I want to keep this PR in copied branch b2. If any bad happened to b1 branch PR which is still not approved (under review), I will overwrite changes from branch b2 with PR. Is it possible? – Brillian Feb 07 '20 at 15:35
-
@TheArcticWalrus - thanks for ur reply. I raised PR in the same branch b1 itself not from other branch – Brillian Feb 07 '20 at 15:40
-
Why would something bad happen to b1? If they PR is refused it will not show in the git log and you will be able to push more commits to b1 and reopen another PR with the fixes from b1. There is no need to have 2 PRs with the same content – TheArcticWalrus Feb 07 '20 at 15:43
-
@TheArcticWalrus -here 'bad happened' means , other developer commits and file changes will be added into my PR while addressing(commit, push and amend) PR reviewer comments ( I am facing the same issue now and I did squash commit but still other developer file changes still there in my PR, I am unable to remove other developer file changes , but I squashed as one commit. That is why I planned to do copy the current branch b1 for safety. so that I can try to delete those file changes without head ache – Brillian Feb 07 '20 at 15:51
-
Ok so you want to have another branch (b2) that does not have the rebased or merged commits from the branch you are trying to do your PR into? If that is the case you can create another branch but having the pr open for that one as well is not necessary nor advised as it will be blocked due to merge conflicts. – TheArcticWalrus Feb 07 '20 at 15:53
-
@TheArcticWalrus - commits are available. but I am afraid of PR reviewer comments. I am going to delete file changes of other developers in my PR under branch b1. As I am a novice, I am not sure whether PR reviewer comments and corresponding highlighted code changes will be retained or not while deleting file changes of other developers. That is why I asked to keep PR reviewer comments and corresponding changes by overwriting histories and PR from branch b2 which is copied. – Brillian Feb 07 '20 at 16:00
-
Do not delete commits from other developers on your branch. The only changes that will show on the PR is the diff between your current branch and the branch you want to merge to. No need to be afraid of PR comments. – TheArcticWalrus Feb 07 '20 at 16:10