Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
Agent-E11 opened this issue Sep 9, 2023 · 14 comments
Closed

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

Agent-E11 opened this issue Sep 9, 2023 · 14 comments

Comments

@Agent-E11
Copy link

Describe the bug

I created a new vault and new GitHub repo.

  • I ran "Obsidian Git: Initialize a new repo"
  • I ran "Obsidian Git: Push"
    • In the text box "Select or create a new remote by typing its name and selecting it" I typed "main" to create a new remote named "main"
    • I got the error "error: No such remote 'main'"

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

  • Create new vault
  • Install "Obsidian Git"
  • Run Obsidian Git: Initialize a new repo
  • Run Obsidian Git: Push
  • Type main into the text box

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
Copy link

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
Copy link

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
Copy link
Owner

Vinzent03 commented Oct 12, 2023

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

@siothelibrarian
Copy link

siothelibrarian commented Oct 13, 2023 via email

@Vinzent03
Copy link
Owner

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

@siothelibrarian
Copy link

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

@ifacodes
Copy link

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
Copy link
Owner

@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
Copy link

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
Copy link

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:

  • on windows you can do something like git --version in powershell, and if you get the version back then it's probably installed correctly, although you can always run winget install --id Git.Git -e --source winget in powershell to get the latest version.
  • on macos you can do the same thing, or update to the latest with brew install git if you have homebrew installed.
    (if you don't have homebrew installed, you can check out https://brew.sh)
  • or check out https://git-scm.com for your relevant system and follow the instructions there. but we want the command line version.

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
Copy link

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
Copy link

yunghoy commented Nov 30, 2023

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
Copy link

ifacodes commented Dec 1, 2023

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? #599 (comment) 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
Copy link

gitet commented Jan 4, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants