I'm aware that an exceedingly similar-sounding question has already been posted here:
Updating a local repository with changes from a github repository
However, my question was not answered by that page. In essence, I updated my GitHub repo with some new files and I edited some old ones on a machine. Now, I have an older version on another machine. How do I update the older version?
This was my error message. I ran sudo git pull origin master
.
error: Your local changes to the following files would be overwritten by merge:
test.py
Please commit your changes or stash them before you merge.
error: The following untracked working tree files would be overwritten by merge:
README.txt
Please move or remove them before you merge.
Aborting
Then I ran
git commit -m "idk this is old but i have to commit n e way even though i just want to update from master?"
Since I was supposed to commit my changes or "stash" them which I have not learned about yet. In addition, I did not know what to do about README.txt so I just left it for now.
[master 16b204e] idk this is old but i have to commit n e way even though i just want to update from master?
3 files changed, 11 insertions(+), 3 deletions(-)
create mode 100644 README
create mode 100644 README.txt
I ran
sudo git pull origin master
again but I got this error:
From https://github.com/bobhob314/fright-before-christmas-clone
* branch master -> FETCH_HEAD
Auto-merging test.py
CONFLICT (content): Merge conflict in test.py
Automatic merge failed; fix conflicts and then commit the result.
I want to know why this happened. Is this a possibility? I don't recall if this is exactly what took place.
- I had version 1 on machine A. I pushed version 1 to GitHub.
- I cloned version 1 from GitHub to machine B. I edited the local repo and pushed it to GitHub, rewriting version 1. We'll call this version 2. Now I have version 2 on GitHub and the local repo on machine B.
- I edited version 1 on machine A by accident to "version 3". (The step that I assume caused the error)
- I tried to pull version 2 from GitHub to machine A's version 3 and it didn't work.
I don't exactly know the under-the-hood mechanics of git, so please help me figure out what went wrong.
Thanks!