Last active
June 25, 2024 01:39
-
-
Save Edyta2801/21f73b751307e751db520256a47d09d1 to your computer and use it in GitHub Desktop.
can't automatically merge
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
https://blog.michelemattioni.me/2013/01/29/what-do-i-do-when-my-pull-request-does-not-merge-automatically-in-master/ | |
Why this happens | |
The problem is that both in master and in your branch some files have been changed, and their going in different directions. The content of the file in master is different from the one in your feature_branch, and git does not know which one to pick, or how to integrate them. | |
To solve this, you need to | |
Get the latest upstream/master | |
Switch to your master | |
merge the latest master in your master (Never develop in master, always develop in a feature branch) | |
switch to your feature branch | |
merge master in your feature branch | |
solve all the conflicts: this is where you decide how to integrate the conflicting files, and this can be done only by you because you know what you did, you can figure out what happened in master, and pick the best way to integrate them. | |
commit all the changes, after all the conflicts are solved | |
push your feature branch to your origin: the Pull Request will automatically update | |
Talk is cheap, show me the commands (cit. adapted) | |
If you didn’t already add the upstream to your repo, have a read to this | |
1. Fetching upstream | |
git fetch upstream | |
2. Go to your master. Never develop here. | |
git checkout master | |
3. Bringing your master up to speed with latest upstream master | |
git merge upstream/master | |
4. Go to the branch you are developing | |
git checkout my_feature_branch | |
5. It will not be fast forward | |
git merge master | |
6. Solve the conflicts. get a decent 3 views visual diff editor. I like Meld | |
git mergetool | |
7. Commit all the changes. Write an intelligible commit message | |
git commit -m "Decent commit message" | |
8. This will push the branch up on your repo. | |
git push origin my_feature_branch |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks for your advise. It's very helpful for me.
Keep in touch.