Home > database >  How about origin repo updates after local `git fetch & git rebase`?
How about origin repo updates after local `git fetch & git rebase`?

Time:10-01

I get a GitHub Workflow snapshot:

enter image description here

In there I have a question:

you know there use git fetch & git rebase for making local repo synchronization with origin, then we can commit and make pull request.

but however there may be this kind of situation, after git fetch & git rebase the origin repo update, when I commit and make pull request, the $user/repo is behind the origin repo.

if in this case, what will happen and how to make solution?


EDIT-01

And I have another question, when step 6, whether is push the branch: myfeature?

and in $user/repo create PR to original/repo, is push the $user/repo branch: myfeature? Whether should the $user/repo master rebase(or merge) the $user/repo branch: myfeature before create pull request to original/repo?

after the created PR, should I delete the $user/repo branch:myfeature and local/repo branch:myfeature?

CodePudding user response:

The step 4 (fetch rebase) is done precisely for the $user/repo to not be behind the upstream repo (the original repository forked)

Your PR branch will be based on the latest from that original repository, and can be pushed to your fork to initiate a PR.

If that PR branch is behind the original repository, you repeat step 4: fetch (of upstream) rebase (or your PR branch on top of upstream/main), plus a git push --force: your PR will be updated, and can be merged without conflict, since any conflict will have been resolved locally during the rebase.

Step 6 is git push -u origin my_feature, and indeed, that feature branch shoul d always be rebased first on top of upstream/main (or "original/main") before doing a PR, in order for that PR to be easily merged by the original repository maintainer.

after the created PR, should I delete the $user/repo branch:myfeature and local/repo branch:myfeature?

Not right away: wait for the PR to be accepted first.

  • Related