Return after Pull request

I have a test function branch. I made my changes and made my changes to this thread. In the meantime, my master advice was changed (suppose it had more commits from other developers).

Before pushing my changes to the remote branch, I did git rebase and then pushed my changes and created a Pull request.

For my transfer request, there were a few comments that I needed to fix.

After the fix, I saw that my master branch was updated. (Assume some more commits from other developers).

At any moment, the reason for merging master into the test branch is as follows: there may be scenarios in which it is necessary to integrate changes into the master and test the application using this function branch

In this situation, I have 2 questions.

  • How can I merge / reinstall new master changes to my test branch without committing a merge in my test branch? This way, I will have both my previous commits, which are part of the Pull request and the new commit, which is a correction of the Pull Request comments.

  • How can I merge / reinstall master on test and add a new commit to my existing previous commit so that I always have one commit in my PR?

+5
source share
1 answer

First of all, determine if you need new changes from master to integrate into your function branch. Perhaps you can ignore new changes with master . If they do not conflict with your changes in test , then this is the easiest thing, and the developer can still combine your PR.

You can easily verify that this is happening by checking out the GitHub PR page. If you get the message β€œcannot be automatically drained”, you will need to use one of the following solutions.


The standard way to enable upstream changes without merging is to reinstall again:

 git checkout test git rebase master 

Since this overwrites the story, you need to force click:

 git push --force-with-lease 

Your PR will be updated with all your commits and will now include new entries in master in its history.

Mandatory Warning . Since rebooting overwrites history, it can be dangerous / destructive for everyone who works in this thread. Be sure to let us know what you have done with someone you work with.

If you do not want to reinstall, your other options are:

  • Combine master into test , but you stated that you did not want to do this.
  • git cherry-pick any new commits to master . This has the disadvantage of duplicating these commits in your branch.
  • Squash the master into test : git merge --squash master . This is similar to cherry-pick , but only creates one commit.
+4
source

Source: https://habr.com/ru/post/1258102/


All Articles