Zulip Chat Archive
Stream: general
Topic: How to merge safely
Etienne Marion (Sep 02 2024 at 08:54):
Hello!
When I want to merge master
into a branch, I do git merge origin/master
, which does the merging fine, and allows me to resolve potential merge conflicts. However in tricky cases (file splitting for instance) it might not behave as I intended, and in such cases I wish I had not done the merge. It is always possible to cancel it, but the question I wanted to ask is:
Is there a way to see what the merging will do to the files I modified on my branch before merging?
I'm using VSCode.
Kevin Buzzard (Sep 02 2024 at 08:59):
The naive approach is just to make a new branch based on your current branch and merge to that instead :-) (that's the sort of thing I'd do, precisely because I'm not a git guru)
Etienne Marion (Sep 02 2024 at 09:00):
Indeed that would work, thanks :sweat_smile:
Damiano Testa (Sep 02 2024 at 09:07):
Does git merge
take a -n
flag that skips the committing step?
Etienne Marion (Sep 02 2024 at 09:18):
Hmm in fact -n
does not do that but there is a --no-commit
option indeed. I'll try it next time. Thanks!
Damiano Testa (Sep 02 2024 at 09:22):
I only used the -n
flag with cherry-pick
and I find it very useful, especially when I am cherry-picking something and then I want to see what else to cherry-pick, without passing all hashes at once.
Eric Wieser (Sep 05 2024 at 17:53):
Another good option is
git tag -f hold-my-oleans
lake exe cache pack
git merge whatever
lake exe cache get
# open some files in vscode and check if they are ok
# if things go wrong
git reset --hard hold-my-oleans
lake exe cache unpack
Julian Berman (Sep 05 2024 at 17:57):
Another thing worth at least being passingly familiar with is the existence of rerere which is not enabled by default. In short (to see if you care to read that page) it can occasionally save you some time performing the same merge multiple times.
Etienne Marion (Sep 05 2024 at 18:22):
Thank you!
Last updated: May 02 2025 at 03:31 UTC