Two Machines - One user for Git/GitHub Repository

Viewed 25

I'm learning to code on TOP and I have been going between my iMac and my Macbook Air. I've installed git on both machines and provided SSH keys for both. Each of my consoles have a local repository and I thought they both can push to Github just fine, but tonight I'm having issues.

I want to be able to go between both of my consoles as I often leave home and like to work on my Macbook. I want to make sure that they both can push/pull from the Github repository and have the most current version at any time.

How is the best way to go about this? Should I have my main branch be one and then create another branch for the other console?

When I run - git status - they both say "On branch main" - I'm wondering if this is the conflict here. It also says when I do - git push - that my branch and 'origin/main' have diverged.

What brought this on is I use VSC editor on both machines and when I went to update the workflow with the source code section and sync changes I got the following error message and now I'm in a rabbit hole trying to figure this out.

Essentially, I want to be able to work from both machines with the same credentials and I'm not sure how to do that.

Please help or reference a thread that could point me in the right direction. VSC Editor Popup

1 Answers

Looking at the error message in the image you linked it doesn't look like your Github authentication is working.

Since you are using Github, I'd suggest using their command-line tool (https://cli.github.com/) which makes handling authentication easier. Have a look at the gh auth login command - it will handle the SSH authentication for you.

To answer your other question regarding branches - you can definitely use just one branch - branches should be about the features etc. you are working on, not about the machines. If you are just one person working on a simple project not meant to be shared with other people, having only the main branch is ok. (You can start learning how to use branches later.) You just need to make sure the local version(s) ("local branches") are in sync with the remote one (origin/main).

The conflicts probably come from the fact that you did not push your changes properly to the remote branch. Beside VS Code, you might want to check out Github's GUI tool Github Desktop which should be more user-friendly. It works well in conjunction with VS Code, which has a built-in merge conflicts editor.

Related