So I’m on this part of the course, but there seems to be something wrong because when I’m at the part to do the “Git Pull” command just like mosh does to do the 3-way merge, I keep getting this error “Pulling without specifying how to reconcile divergent branches is discouraged”, not allowing me to finish the pull while it does for Mosh. I followed everything so far precisely how he does it but for some reason, it’s working for him and not for me (unless I do git pull -rebase which I didn’t want to do).
Are you absolutely certain you are doing everything exactly like Mosh? If you have divergent branches, that means that you have conflicting changes between what you changed on GitHub and what you changed locally. Mosh avoided that by changing README on GitHub and adding a whole new file on the local branch.
Can you share your GitHub link and then what your local history looks like (eg. the output of git log -p
)?
Another possibility is that this is just a warning and it actually did the merge anyway: git merge - How can I deal with this Git warning? "Pulling without specifying how to reconcile divergent branches is discouraged" - Stack Overflow
To retain default behavior and get rid of the warning, you should be able to run:
git config --global pull.ff true
Yeah, I deleted/restarted my local and remote repo and did the whole thing again exactly how mosh did it and I’m still getting the error. Specifically, it says “Need to specify how to reconcile divergent branches.”
This is my remote Repo: GitHub - sharktankful/Mars
I could do that but I first just wanted to follow how he did it first and not get lost in any of the videos later on in the course.
If you do this, it should just be explicitly setting the default, but silencing the warning. So you should not be worried about diverging from Mosh’s setup.
I think I somewhat understand so I’ll try that.
To give an update, I did try that and it did create the same exact result as in the video so thanks!
Git’s merge strategy defaults to “recursive”, but in Git 2.30 and later, a new merge strategy “ort”, also known as “Ostensibly Recursive’s Twin”, was introduced. The “ort” strategy fixes some issues with the “recursive” strategy and is significantly faster in large repositories, especially those involving many renames.
If you want to change Git’s merge strategy from “ort” to “recursive”, you can use the following command:
git config --global merge.strategy recursive
This command sets the merge strategy in Git’s global configuration to “recursive”. Thus, when you execute the git merge
command, Git will use the “recursive” strategy by default.
Please note that although the “recursive” strategy is Git’s default strategy, the “ort” strategy may perform better in some cases. Before switching merge strategies, you might need to consider your specific needs and the pros and cons of these two strategies.