Two devices - One GitHub Repo _ What is the correct way to update your files across devices without losing your data?

First of all, thank you so much. This community is incredible.
I am writing my dissertation, so I have obsidian on my working computer and on my personal computer backed up on github. The problem is, everytime I modify something in my work computer and push to github and later try to update the same version at home, I receive an error and also this (origin/main) appears written on my document.

What is the correct way to update your files across devices without losing your data?

Should I pull and then push? What is the right order of actions I must take?

Thank you

what error? :man_shrugging:

It says the merge failed - the file cannot be updated. Then origin/main appears written in my file. I think that I need to either pull or push, i.e., update the file before anything else, but I am unsure what to do first.

Pull = Download
Push = Upload

It’s generally recommended or standard practice before pushing to pull, but…better safe than sorry: finish on one device: add+commit+push. Then on the other one, pull. When you have merging isssues, you’ll have a hard time in a terminal.

I recommend StackOverFlow website for reading and asking questions on all things git, not Obsidian Forum.
Thanks

Git is a system that allows you to selectively ‘commit’ changes that have been made to files in a folder and provide short update messages. You can either commit these updates to a ‘main’ branch or a new branch with a name of your choosing.

When committing and pushing to the ‘main’ branch from device A, and making another commit and pushing to the ‘main’ branch from device B, git wants to know which updates take precedence when pulling them in from a remote repository (GitHub) on either device.

It will mark the lines in the conflicting files with arrows like so:

<<<<<<< HEAD
Some text
=======
Some conflicting text
>>>>>>> branch-a

It is up to you to decide which text to keep by deleting the arrows and removing unwanted text. For more detailed info on how to resolve conflicts, see:

1 Like

Well, the very first thing you should do is backup safe copies of your data. Just in case you overwrite some notes in one of your steps.

git can get tricky sometimes with these merge conflicts. I personally use (and pay for) Git Tower as a helpful GUI interface. That won’t solve your problem, but it makes it easier to learn and use git, in general.

If you have some merge conflicts, you might also have to git stash to store some fixes on one side, before pulling. And then commit those stashed changes afterwards.

But I’ve personally gotten stuck in similar situations. There is even an XKCD comic about git where it jokes that sometimes you have to just delete the whole repo and pull fresh.

Depending how you are stuck, there might not be any simple 1. 2. steps to take that will work in every situation.

You might want to learn and practice git commands on an unimportant repository, before relying on it for your dissertation.

Thank you. So, I have a machine at home and another one at my workplace. I write at home during the weekend, but when I get to work, I pull and it says there is nothing to pull, even though I have committed my work to github. So I push at the end of the day and it is on my github when I get home. I do not know what I am doing wrong and if I am overwriting anzthing and losing work on my dissertation.

How or where should I backup those copies? Google docs? Sorry if I am a newbie.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.