Vinzent03 / obsidian-git

Integrate Git version control with automatic backup and other advanced features in Obsidian.md
MIT License
6.85k stars 294 forks source link

[Bug]: error: no such remote 'main' #599

Closed Agent-E11 closed 10 months ago

Agent-E11 commented 1 year ago

Describe the bug

I created a new vault and new GitHub repo.

How do I create a new remote?

Relevant errors (if available) from notifications or console (CTRL+SHIFT+I)

git obsidian error: error: No such remote 'main'

Steps to reproduce

Expected Behavior

Create a new remote named 'main'

Addition context

I have also tried the names: remote and master This isn't really a "bug report" but there aren't any other issue templates

Operating system

Windows

Installation Method

None

Plugin version

2.22.0

catherinetcai commented 1 year ago

Ah, the docs seem to assume a certain familiarity with git.

When we refer to "main" or "master", that's the git branch name, not the remote.

When Obsidian Git is asking to create a new remote, it's asking for the remote URL (in this case, the GitHub repo URL) you're going to be syncing your notes to.

To find the remote URL, navigate back to page with the GitHub repo you created. You'll want to click on the <> Code button. It'll give you the HTTPS URL you should be using. (I included a screenshot with what it should look like.)

Screenshot 2023-09-25 at 12 24 52 PM

I would also make sure that you set up your git credentials. You need to be able to authenticate to GitHub before you can sync your notes using git. GitHub has a decent set of steps for how to do this here.

siothelibrarian commented 1 year ago

I think there's something else going on here - I've been using Obsidian Git for months, and all of a sudden, I'm getting a similar error. Whenever my vault tries to push a change, I get an error that says "No upstream branch is set." I only have one branch, but when I type "main" into the dialog, I get the same error: No such remote "main."

There doesn't seem to be an issue with my authentication - I can push changes from Git Bash on my machine, but I can't tell why it's not working through Obsidian. I tried to check in the plugin settings (the "Getting Started" page of the documentation says there should be an "Authentication/Commit Author" section that doesn't seem to exist anymore) but there's nothing there that would give me any clue what's going on.

Vinzent03 commented 1 year ago

May you please share your .git/config file in your vault/repo?

siothelibrarian commented 1 year ago

Hi,

Sure, see attached.

On Thu, Oct 12, 2023 at 8:09 AM Vinzent @.***> wrote:

May you please share your .git/config file?

— Reply to this email directly, view it on GitHub https://github.com/denolehov/obsidian-git/issues/599#issuecomment-1759584695, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACPRJG65FI65VVX3XDJYSEDX67TY5ANCNFSM6AAAAAA4RWJDUE . You are receiving this because you commented.Message ID: @.***>

-- Siobhain


Siobhain Rivera (she/her) MLS, Digital Libraries @.***

Vinzent03 commented 1 year ago

This doesn't work with GitHub. There's nothing attached.

siothelibrarian commented 1 year ago

Sorry, the email indicated I could just reply. -_-;; See attached. config.txt

ifacodes commented 1 year ago

I'm also encountering this, I had to add both the remote and the upstream branch manually with git (i.e, git remote add origin "git@etc.git" and git push -u origin main) for the plugin to recognize either. it seems the create a new remote, and create a new upstream branch commands are broken.

Vinzent03 commented 1 year ago

@siothelibrarian You might try the commands from ifacodess for now. Your shared config seems to be the global one and not the in your git repository under <repo>/.git/config

ekkaiasmith commented 1 year ago

I'm also encountering this, I had to add both the remote and the upstream branch manually with git (i.e, git remote add origin "git@etc.git" and git push -u origin main) for the plugin to recognize either. it seems the create a new remote, and create a new upstream branch commands are broken.

@ifacodes where do you type these commands?

ifacodes commented 1 year ago

using a terminal of some kind!

for example, I am on macos, so I would use terminal, (or to be more precise I use iterm2), althought if you are on windows you should probably use powershell. you do need to make sure you have git installed on your system:

once you are certain git is installed, you also need to verfiy you have initialized git in your vault. assuming you initialized it through the plugin, that should already be the case, if not, navigate to the main/root folder of your Vault (this should be the folder that contains .obsidian), and run git init.

as an example, for me on macos this is in /Users/ifa/Library/Mobile Documents/iCloud~md~obsidian/Documents/ifa/it may look different for you, or be in a different location on windows, etc.

create a new, empty github repo, name it whatever you want, and copy the https or ssh url, depending on which one you have setup to use.

to set that repo as the remote for your vault, enter git remote add origin git@github.com/YOUR_USERNAME/YOUR_REPO.git if you are using SSH or git remote add origin https://github.com/YOUR_USERNAME/YOUR_REPO.git if you are using HTTPS.

finally push your vault to the upstream repo with git push -u origin main.

I tried to be thorough in case anyone came across this issue and is new with git or source control. let me know if you have anymore questions.

kamilsztuke commented 1 year ago

Please check repo main branch name , for me plugin stopped working with main branch name "main" after many tries I've changed main branch name to "master" and clone succeeded

yunghoy commented 11 months ago

I'm new to Obsidian. I tried this but it's not working as well. I have master branch on remote and commits. Can you provide us how to debug this? Nvm.. I think I can use CLI instead of using the plugin.

ifacodes commented 11 months ago

I'm new to Obsidian. I tried this but it's not working as well. I have master branch on remote and commits. Can you provide us how to debug this? Nvm.. I think I can use CLI instead of using the plugin.

Did you follow what I posted above? https://github.com/denolehov/obsidian-git/issues/599#issuecomment-1805646855 is not truly a valid fix to this issue, that sounds like it is dependant and the git version installed on your system, as most up to date git versions no longer support 'master' as the default branch.

gitet commented 10 months ago

I just ran into the same problem. I had to add the remote via cli: git remote add origin git@github.com:MYUSERNAME/obsidian-vault.git (using ssh auth) Then git push -u origin main - note the use of main here, not master - so the problem is not related to main/master naming. After this, obsidian picked up the repository just fine.