Simple git fetch/ merge - same branc names local and remote - not working #183935
Replies: 1 comment 1 reply
-
|
Nothing you did is silly. This is a very common Git confusion. The issue is not the editor, not the branch name, and not the remote URL. Even though both users started with the same files, they did not start with the same Git history. Git does not care that the HTML files look identical. Git only cares about commits and their ancestry. Here’s what happened: User AAA created the repository and made the first commit. User BBB did not clone the repository. Instead, the folder was copied manually. Because of that, user BBB created a completely separate Git history, even though the files were the same. So when BBB runs: git fetch Git correctly downloads AAA’s commits and stores them as origin/master. But when BBB tries: git merge origin/master Git refuses because BBB’s local master branch and origin/master do not share a common ancestor commit. From Git’s perspective, these branches come from unrelated projects, so it doesn’t know how to merge them safely. That’s why Git says: origin/master - not something we can merge This is exactly what Git is supposed to do. The correct way this should be done For collaboration, every contributor must start with git clone, not a copied folder. User BBB should have done: git clone https://remote1.git That way: Both users share the same commit history fetch, merge, and pull all work normally Changes can be “ping-ponged” safely After cloning, BBB could simply run: git pull and AAA’s changes would appear. Extra (why Git allows forcing it) If someone really wants to merge anyway, Git allows it with: git merge origin/master --allow-unrelated-histories But this is only for special cases and learning. In real teamwork, cloning is the correct solution. The key takeaway Same files ≠ same Git project. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
hi all!
And a Happy New Year for 2026 to everyone!
What i am about to ask may sound silly and might make you laugh...but here it goes:
In learning Git, one crucial step is retrieving changes done by someone else and integrating them into your own (before pushing (uploading) your own work into the remote repo).
With that said, i made 2 accounts with different user names - user AAA and user BBB.
On user AAA, i se VSCode with terminal and for user BBB, i used KATE editor (yes, the one from Linux...) with terminal.
Locally, each user is on the default master branch.
So 2(two) users with different editors, but both are configured for the same remote repo: https://remote1 (example name).
The command used to configure the remote repo (for both users!) was:
git remote add origin https://remote1.git (the link for that remote repo - created in the Github account of user AAA).
Also, the remote1 repo was created in advance, in the GitHub account of user AAA.
It has only 1 branch, the default master branch.
The idea is really simple - for each users, i duplicated same initial folder with the most basic of web page (just a tiny sample with 1
in it...thats it).
So both users have the SAME starting folder with the same .html file.
They are thus identical...for now !
User AAA added one more paragraph, a simple < p >tag (a simple phrase...) in his .html then commits and then does git push -u origin master into that remote repo (which worked great!)
The idea was that user BBB - who hasnt yet modified his file! his .html file is still "virgin" - does fetch to retrieve the "work" done by user AAA and then tried to do a merge, so whatever user AAA did (that extra
phrase), should also appear in user BBB's pristine, unchanged file.
Remember - both users are on their local (default) master branch. Also, that remote repo1 is on (default) master too!
The idea is to "ping pong" changes between users - one of them commits, then pushes and the other retrieves and integrates the work done by the other.
Except..here i run into issues!
When user BBB runs git fetch --all, it works well! No errors!
But when user BBB runs the command git merge origin/master, returns:
merge: origin/master - not something we can merge
Why doesnt it work ?!
Origin is defined identically in both users!
Thanks
Beta Was this translation helpful? Give feedback.
All reactions