atom / github

:octocat: Git and GitHub integration for Atom
https://github.atom.io
MIT License
1.11k stars 392 forks source link

unable to fetch and pull #2430

Open rahulsps opened 4 years ago

rahulsps commented 4 years ago

Prerequisites

Description

When I try to fetch / pull through atom (1.45.0) on my machine (Ubuntu 16.06), it says fatal: Couldn't find remote ref refs/heads/pentdev but git fetch and git pull works fine on cli

Steps to Reproduce

  1. Clone a git repo on machine from cli
  2. Open repo in atom IDE
  3. Press git fetch button from git pane on the right side

Expected behavior:

Fetch and pull commands should work properly

Actual behavior: Unable to fetch and pull

It throws above mentioned error

Reproduces how often: Reproduces Everytime

100%

Versions

Atom : 1.45.0 Electron: 4.2.7 Chrome : 69.0.3497.128 Node : 10.11.0

Additional Information

logs.txt logs-cli.txt

Hjalmar-Thunberg commented 4 years ago

Having the exact same problem.

nickjbell commented 4 years ago

sam eissue

pablomikel commented 4 years ago

I'm having this issue as well. Everything works fine through Terminal but when I try fetching through Atom I receive the "fatal: Couldn't find remote ref refs/heads/xxx" error.

vighnesh153 commented 4 years ago

The Github plugin works perfectly fine on the Windows machine. It is completely broken on Mac. I can't perform Github operation like fetch, pull, push on any repo. Works on the CLI though.

smashwilson commented 4 years ago

I spent a bit of time trying to debug this with @rahulsps in Slack before asking him to open this issue and tbh I'm a bit stumped. I also can't reproduce. Since there are a number of you experiencing this now, can you confirm a few assumptions for me?

  1. What Atom versions and OSes are all of you using?
  2. Are you all attempting to fetch HTTPS remotes?
  3. Is the repository you're attempting to fetch a private repository?
  4. Are you authenticating with the OAuth token? (If you use any git credential caching or helpers outside of Atom, Atom will prefer those. So: When you try to fetch with Terminal, are you prompted every time for your username and password?)

My best guesses based on the information I have so far is that this could be related to (a) a upgrade of the bundled git that happened in a recent Atom update, or (b) some change in GitHub's oauth scopes and permissions related to git operations that I haven't followed.

Spare time to bugfix here has been scant recently, so I don't know how soon I'll be able to try to take a deeper look again. Hopefully I'll get a few minutes this weekend?

brycekunkel commented 4 years ago

I was having this issue on a different computer earlier this week, running Atom 1.45.0, and OS X 10.15.4. I upgraded my laptop this week (I no longer have the old one), and am no longer having this issue.

The old Macbook I had upgraded from Mojave to Catalina. I was on an older version of Atom and didn't have this issue, but when I tried to upgrade Atom from the menu bar, it gave me an error telling me that Atom was installed on a read only volume. Reinstalling Atom fixed the first issue, but gave me this one.

ghost commented 4 years ago

Same issue here, I can't pull/fetch without getting the error "fatal: Couldn't find remote ref master" but git cli works just fine. However, pushing via Atom does work.

I can confirm everything also works fine on my Ubuntu (19.10) box running the same Atom version.

I'm fetching from GitHub via https and I'm pretty sure I'm using OAuth since I'm not prompted for credentials from the command line every time and Atom never prompted me for credentials.

Atom: 1.45.0 x64 Electron: 4.2.7 Chrome: 69.0.3497.128 Node: v10.11.0 MacOS: Catalina 10.15.4

smashwilson commented 4 years ago

Oh - A quick way we could narrow it down to a token problem. Can one of you visit https://github.atom.io/login and use the token copied from there as your password when you fetch? Let's see if you the same problem or not.

ghost commented 4 years ago

Logged in to GitHub using the token. Tried both fetching and pulling. Getting a slightly different error, but along the same lines: "fatal: Couldn't find remote ref refs/heads/master". Using the Git tab instead of the GitHub tab I still get "fatal: Couldn't find remote ref master".

Verified pull still works without issue via CLI.

smashwilson commented 4 years ago

No, try using that token instead of your password on the command line. (Sorry, brain is fried and I totally didn't mention that in my question 😂 )

nicktramp commented 4 years ago

Piling on... tried the token via CLI and received the same error as trying to fetch in Atom: "remote: Repository not found. fatal: repository 'https://github.com/myOrg/myRepo.git/' not found" (org & repo changed, of course)

OS: Linux Mint 18.3 x64 Atom : 1.43.0 Electron: 4.2.7 Chrome : 69.0.3497.128 Node : 10.11.0

Repo is private, accessing over https with no OAuth (entering credentials via CLI every time; works fine). Also, no credential caching or helpers outside Atom.

ghost commented 4 years ago

OK, so make sure I did this right since I'm NOT a git expert. I deleted the local directory and cleared my cached credentials. I re-cloned the repo and instead of using the username/password used the token.

That worked without any issue. Cloned the repo without error and git pull via CLI still works just fine without error. Atom still gives the same errors previously. I can also still push via Atom without issue.

Did I do that right and does that help?

smashwilson commented 4 years ago

Piling on... tried the token via CLI and received the same error as trying to fetch in Atom

Ahhh so it is a token issue. Now I just have to figure out why my token is fetching from private repos fine, but none of yours are... ?

Can one of you try this?

curl -s -I -u ${GITHUB_USERNAME}:${ATOM_IO_TOKEN} https://api.github.com | grep X-OAuth-Scopes:

For reference, mine shows the following:

X-OAuth-Scopes: read:org, repo, user:email
ghost commented 4 years ago

The token appears to work fine for me via CLI. I ran the code above and this is the result.

X-OAuth-Scopes: read:org, repo, user:email

nicktramp commented 4 years ago

My output:

X-OAuth-Scopes: read:org, repo, user:email

smashwilson commented 4 years ago

Wait - @nicktramp, your CLI output is different: it says "repository not found," not "Couldn't find remote ref."

Do you use multiple GitHub accounts? Are you sure your token was generated with the correct user? You can check like so:

curl -u ${GITHUB_USER}:${ATOM_IO_TOKEN} -s https://api.github.com/user | grep login
nicktramp commented 4 years ago

Just the one account. Tried a fetch on other private repos outside the org from Atom with success; all those tested that belong to the org are failing. Could the tokens have some permissions incorrectly set? I'm an admin of each repo I've tried, and org owner. If it's relevant, I switched to using ssh on the first-mentioned repo (rather than https) by git remote set-url on CLI, then fetch works fine in Atom. I also have to admit I don't know the workings of how the tokens are used by Atom, so I'm at risk of becoming useless for this issue. However, just mention me and I'll test whatever you need to help fill in the picture.

nicktramp commented 4 years ago

Wow; I feel dumb. For my case, I simply didn't grant org access to the Atom GitHub package for the org. Sorry for the confusion.

smashwilson commented 4 years ago

Oh! Yeah, that'll do it. No worries... that's a point of friction we never really found a good answer for.

rahulsps commented 4 years ago

@smashwilson

root@user-HP:/var/www/html/# curl -u ${rahulsps}:${token} -s https://api.github.com/user | grep login
root@user-HP:/var/www/html/# curl -s -I -u ${rahulsps}:${token} https://api.github.com | grep X-OAuth-Scopes:

Prints nothing at all

smashwilson commented 4 years ago

@rahulsps: Did you set the environment variables rahulsps and token to your username and token, respectively? What are the full responses (without the | grep ... parts)? Did you confirm that you see the same error when you use your token in place of your password with running git fetch on the command-line?

(Since @nicktramp's problem turned out to be org permissions, and their error message was different, we have not yet confirmed that it's the token which is causing problems.)

rahulsps commented 4 years ago

atom used to work fine till march 2020, after that something has happened and there is definitely some changes in scope because an alert also used to appear which i overlooked then and without grep it says

bash: ${rahulsps}:${token}: bad substitution
rahulsps commented 4 years ago

@smashwilson when i try to clone a repo using this token it works

smashwilson commented 4 years ago

atom used to work fine till march 2020, after that something has happened and there is definitely some changes in scope because an alert also used to appear which i overlooked then

That's strange, because we haven't changed the scopes on that token since 2018, when I was working on this full-time.

You ignored an alert about the token? In Atom? Have you tried logging out (by running GitHub: Logout from the command palette) and logging back in with a new token that has the correct OAuth scopes?

and without grep it says

bash: ${rahulsps}:${token}: bad substitution

Okay, that's because you aren't actually setting those environment variables anywhere. I can't give you a command that you can copy and paste without any changes because I don't (and shouldn't) know your token. I was implying that you should substitute your real token and username, either by setting them as environment variables in your shell or just substituting them directly.

What you actually need to do is:

$ export GITHUB_USERNAME=rahulsps
$ export ATOM_IO_TOKEN=.... # Paste the token that you copy from https://github.atom.io/login here exactly
$ curl -s -I -u ${GITHUB_USERNAME}:${ATOM_IO_TOKEN} https://api.github.com | grep X-OAuth-Scopes:
$ curl -u ${GITHUB_USER}:${ATOM_IO_TOKEN} -s https://api.github.com/user | grep login

@smashwilson when i try to clone a repo using this token it works

This implies that the token isn't the problem, though?

jfdumont commented 4 years ago

I am facing the same problem Os : Fedora 32 git version 2.26.2

Atom: 1.45.0 Electron: 4.2.7 Chrome: 69.0.3497.128 Node: 10.11.0

Worked very well until Friday ( I upgrade from Fedora 31 to 32 this week-end, coincidence ?) and today no more push or pull on all repositories !

with message

/bin/sh: erreur lors de l'importation de la définition de fonction pour « module »
/bin/sh: scl: ligne 1: erreur de syntaxe : fin de fichier prématurée
/bin/sh: erreur lors de l'importation de la définition de fonction pour « scl » 
fatal: Couldn't find remote ref refs/heads/master" 

i logout and login atom from github On Github i revoke access and re-enable access

curl -u ${GITHUB_USER}:${ATOM_IO_TOKEN} -s https://api.github.com/user | grep login
  "login": "jfdumont"
curl -s -I -u ${GITHUB_USERNAME}:${ATOM_IO_TOKEN} https://api.github.com | grep X-OAuth-Scopes:
X-OAuth-Scopes: read:org, repo, user:email

I confirme i can git pull and push using cli

saiv123 commented 4 years ago

yes i have having a simillar problem, so everything working fine except when it is trying to push or pull the url it is trying to pull from is something like github.com/username/repo.git/ when its supposed to be github.com/username/repo.git

fallengravity commented 4 years ago

I started getting this issue recently too.

macOS: 10.15.5 (19F96) Atom : 1.47.0 Electron: 5.0.13 Chrome : 73.0.3683.121 Node : 12.0.0

When I run atom with:

/Applications/Atom.app/Contents/MacOS/Atom

It constantly outputs:

bash: cannot set terminal process group (-1): Inappropriate ioctl for device
bash: no job control in this shell

Not sure if that's part of the issue.

sean-rose commented 4 years ago

I'm having this problem as well. Here's what I get with GIT_TRACE turned on (user/repo-specific bits have been replaced with generic <placeholders>):

Unable to fetch

11:29:54.223335 git.c:440               trace: built-in: git fetch origin refs/heads/master
11:29:54.239494 run-command.c:663       trace: run_command: GIT_DIR=.git git-remote-https origin https://github.com/<github-org>/<github-repo>.git
11:29:54.862694 run-command.c:663       trace: run_command: 'git credential-osxkeychain get'
11:29:54.882837 git.c:703               trace: exec: git-credential-osxkeychain get
11:29:54.884143 run-command.c:663       trace: run_command: git-credential-osxkeychain get
11:29:55.087290 run-command.c:663       trace: run_command: 'git credential-osxkeychain store'
11:29:55.095016 git.c:703               trace: exec: git-credential-osxkeychain store
11:29:55.095768 run-command.c:663       trace: run_command: git-credential-osxkeychain store
11:29:55.161205 run-command.c:663       trace: run_command: '/tmp/github-2020629-87092-1abtdxv.blwr/git-credential-atom.sh store'
git-credential-atom: working directory = <local-repo-path>
git-credential-atom: socket address = unix:/tmp/github-2020629-87092-1abtdxv.blwr/helper.sock
git-credential-atom: action = store
git-credential-atom: parsed from stdin: [protocol] = [https]
git-credential-atom: parsed from stdin: [host] = [github.com]
git-credential-atom: parsed from stdin: [username] = [<github-username>]
git-credential-atom: parsed from stdin: [password] = [******]
git-credential-atom: all input received: EOF from stdin
git-credential-atom: discover credential helpers from system git configuration
git-credential-atom: PATH = <path-env>
git-credential-atom: discovered system credential helpers: "osxkeychain"
git-credential-atom: attempting to run approve with user-configured credential helpers
git-credential-atom: GIT_ASKPASS = 
git-credential-atom: SSH_ASKPASS = 
git-credential-atom: arguments = -c credential.helper=osxkeychain credential approve
git-credential-atom: stdin =
protocol=https
host=github.com
username=<github-username>
password=*******
git-credential-atom: success
fatal: couldn't find remote ref refs/heads/master
llaurini commented 3 years ago

Same issue, same messages. Worked perfectly on Debian Linux till July.... now work only on windows 10

TIandF-DJ commented 3 years ago

Newer to all of this, just tinkering with some projects. Still having this issue on a fresh install of Ubuntu 20.10. Tested the token with both login and X-OAauth-Scopes: and even without any grep and with multiple tokens (get a new one ever time I load the page) and all are returning bad substitution errors. I think I've tried everything I can here, has anyone found a solution?

TIandF-DJ commented 3 years ago

This issue seems to have been fixed in the newest version, I noted I was running a version or two behind.

Thank you!

SveinnEirikur commented 3 years ago

Same issue, same errors.

macOS: 10.15.7 (19H114) Atom: 1.53.0 x64 Electron: 6.1.12 Chrome: 76.0.3809.146 Noder: v12.4.0

curl -u ${GITHUB_USER}:${ATOM_IO_TOKEN} -s https://api.github.com/user | grep login results: X-OAuth-Scopes: read:org, repo, user:email

git fetch https://${GITHUB_USERNAME}:${ATOM_IO_TOKEN}@github.com/${GITHUB_USERNAME}/${REPO_USERNAME}, git fetch git fetch https://${GITHUB_USERNAME}:${ATOM_IO_TOKEN}@github.com/${GITHUB_USERNAME}/${REPO_USERNAME} and git pull from command line work as expected so probably not token related.

Atom fetch and pull both result in: fatal: couldn't find remote ref refs/heads/master Atom push works as expected.

v86 commented 3 years ago

I had this for days on my macOS 11.1 machine whilst all did well on my macOS 10.15 MacBook. Pushing worked, fetching resulted in the above error.

I just deleted ~/.gitconfig now, even though it only had my username and email address in it. After I restarted atom, it asked for both again and now everything works fine – even though the new ~/.gitconfig contains the same data as before...

SveinnEirikur commented 3 years ago

Tried removing ~/.gitconfig, restarting and resupplying information in Atom, no change.

bmos commented 3 years ago

I am having this issue also. I can push without issue, but when fetching I get "fatal: couldn't find remote ref refs/heads/main". I have removed ~/.atom and reconfigured and also deleted the projects and re-cloned using the gh commandline utility.

dquark commented 3 years ago

Repo is private, accessing over https with no OAuth (entering credentials via CLI every time; works fine). Also, no credential caching or helpers outside Atom.

Changing from HTTPS to SSH and setting up key in /.ssh named id_rsa and connecting id_rsa.pub to github account in settings seems to fix that issue

peasead commented 3 years ago

I was having this issue and ended up finding that I'd installed Atom manually at some point, and then with Brew, and never totally removing one or the other. I think maybe the two of them were leg wrestling?

Used AppCleaner to get rid of all the Atom files brew remove atom

I blew away:

/usr/local/bin/atom
~/.atom
/usr/local/bin/apm

Reinstalled Atom using brew install atom.

Atom picked up my Git config and I was off to the races.

kklooors commented 2 years ago

I use Atom and Github Desktop. When right-clicking on repo in GHD app and selecting "Open in Atom", everything works fine. That is until I reopen the Atom, then I get the fatal error "repo not found".

I tried removing the following: keychain items related to github, GHD app, Atom app (and leftover files). Nothing seems to work. Is there any easy solution for this issue?

Anders-1 commented 2 years ago

I was having the same problem. It turns out my remote on github didn't have the branch I was trying to pull. Fixed it by creating the branch on github.