Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: command to simulate Merge/Pull Request #1120

Merged
merged 1 commit into from
Dec 16, 2023

Conversation

Magador
Copy link
Contributor

@Magador Magador commented Dec 15, 2023

  • Adds git merge(M|P)R <source_branch> <target_branch> [--delete-after-merge] command to simulate a Merge/Pull Request being merged into the target branch
  • The optional flag --delete-after-merge will remove the merged branch on the origin tree
    • The local remote branch remains as it is Git default behavior, even after git fetch (it would require git fetch --prune support to automatically prune remote tracking branches)
  • You can push a branch with a deleted remote tracking branch on origin, the ref will just update.

Resolves #1057

Examples

Merging a feature branch feat into main on origin

git clone;
git switch -c feat;
git commit;
git push;
git fakeTeamwork;
git mergeMR feat main;

image

Merging a feature branch feat into main on origin when deleting it after merging

git clone;
git switch -c feat;
git commit;
git push;
git fakeTeamwork;
git mergeMR feat main --delete-after-merge;

image

If you git fetch after using git mergeMR, the ref o/feat will still exist because git fetch does not prune it by default:

git fetch;

image

You can re-push the local branch, re-creating a remote branch, and updating the ref o/feat:

git commit;
git push;

image

- Adds `git merge(M|P)R <source_branch> <target_branch> [--delete-after-merge]` command
to simulate a Merge/Pull Request being merged into the target branch
- The optional flag `--delete-after-merge` will remove the merged branch on the origin tree
  - The local remote branch remains as it is Git default behavior, even after `git fetch`
(it would require `git fetch --prune` support to automatically prune remote tracking branches)
- You can push a branch with a deleted remote tracking branch on origin, the ref will just update.

Resolves pcottle#1057
Copy link

netlify bot commented Dec 15, 2023

Deploy Preview for xenodochial-hugle-b9ec84 ready!

Name Link
🔨 Latest commit acffcc1
🔍 Latest deploy log https://app.netlify.com/sites/xenodochial-hugle-b9ec84/deploys/657c9f925cf72c0008088eba
😎 Deploy Preview https://deploy-preview-1120--xenodochial-hugle-b9ec84.netlify.app/
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@pcottle
Copy link
Owner

pcottle commented Dec 16, 2023

Wow @Magador I really appreciate the contribution! You wrote tests and explained the small change in the git engine and thought about everything 🙌🏻

I'm not super familiar with these alternate workflows for merging features (at Instagram we all just merge into one main trunk branch) but sounds like you've thought about these a lot. I'll merge and push the site now with the updates 😎

@pcottle pcottle merged commit 9f82317 into pcottle:main Dec 16, 2023
4 checks passed
@IT-VBFK
Copy link
Contributor

IT-VBFK commented Dec 16, 2023

Yeah :)

thanks @Magador

@HenryChan-Git
Copy link

that's good ! Where can i do this experiment ? I do not find this one in https://learngitbranching.js.org/?locale=zh_CN

@Magador
Copy link
Contributor Author

Magador commented Feb 1, 2024

that's good ! Where can i do this experiment ? I do not find this one in https://learngitbranching.js.org/?locale=zh_CN

You can simulate a merge using the sandbox and creating a remote repo :

git clone;
git switch -c feat;
git commit;
git push;
git fakeTeamwork;
git mergeMR feat main;

@HenryChan-Git
Copy link

yes, it works

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants