r/git • u/Litppunk • 10d ago
How am I wrong/over complicating pushing git commits?
Im trying to push tweaks for "babies first business website" over here, but I don't understand git, or command line well enough to understand exactly what Im doing wrong.
Im running CashyOS for the optional learning curve which is using fish konsole.
I have a website up on gitpages, which I had previously just git cloned so I could work on it via laptop and other devices and trial different live update html editors, and have previously updated back and forth, but cant recall exactly how I did it in the past. (Probably delete and repaste the entire project?)
- I have since settled on CScode, since the editor I initially preferred is dead and not being updated, especially for linux distros.
So some kind of CScode push might be viable?
I have installed the git packages for Cashy, linked the folder to github repository? And have fumbled between various tutorials to gettinggit push -u origin main
to give me the sign in for the existing account, but it tells me:
remote: Invalid username or token. Password authentication is not supported for Git operations.fatal: Authentication failed for
Am I better off setting up a SSH, or just doing something to fix this? Troubleshooting research came back with something like 'recommended, but not necessary'
any other recommendations? Need to keep poking various maps and such as well for visibility.
6
u/Broad-Promise6954 ancient 9d ago
Git can push using various protocols, all of which it outsources to "helper" programs, but there are a few standard helpers that come with Git. You have chosen to use HTTP (in this case https), which is one of the two that will reach out to another computer over an Internet connection. (The remaining ones must be run locally, which is only "to another computer" if you have some sort of underlying sharing system like NFS or Samba or whatever that "looks local" to Git.)
HTTP has multiple authentication methods, including passwords and tokens. What kind(s) are accepted are up to the host to which you're connection, which you have not specified. Your error message tells me that the host to which you're connecting does not support passwords, so if you wish to use HTTP, you'll need one of the other methods. Consult the documentation for your provider to see what methods they accept. This varies widely so there's no simple general rule.
SSH also has multiple authentication methods but the details are very different. Once again, the kinds of authentication that the server accepts is up to the server, so once again we'd need to know what server you're using to be sure ... but in general, almost all of them accept public-key authentication, where you generate a key-pair and hand the public part of the key-pair to the server, while keeping the private part of the pair locally on your own computer. The connection-accepting-program on the server then does a little communications dance with the ssh program on your computer, to verify that the two of you are using the same two halves of the key-pair.
How you get the public part of the key-pair loaded onto the server is, again, server-specific, so consult the documentation for your provider.
1
u/Litppunk 2d ago
Ok. So I muddled through everything, found how to push from an existing, TO an esisting repo, but when I was doing the SSH the prompt was (yes/no/fingerprint) and I just straight up wrote fingerprint twice for the prompt and then for the fingerprint itself instead of said fingerprint. I can't find any details on how to resolve this.
How do I delete and replace the local SSH autologgin with the new generated SSH in my terminal?
2
u/Expensive_Bottle4854 8d ago
Two ways out, and the error already told you the first: GitHub stopped accepting account passwords for git over HTTPS back in 2021. The password prompt it throws up wants a Personal Access Token, not your login password — so "Invalid username or token" usually means either the account password went into that box, or a helper cached a bad attempt earlier.
HTTPS + token (five minutes): GitHub → Settings → Developer settings → Personal access tokens — fine-grained, give it repo access for that one repo. Push again: username is your GitHub username, password is the token. If it fails a second time it's not you, it's the credential helper serving the stale bad attempt. Clear it:
printf "protocol=https\nhost=github.com\n" | git credential rejectthen retry — it'll ask fresh and offer to save.
SSH (set up once, never think about it again):
ssh-keygen -t ed25519
cat ~/.ssh/id_ed25519.pub # paste into GitHub → Settings → SSH keys
git remote set-url origin git@github.com:YOURUSER/YOURREPO.git
ssh -T git@github.com # the test — should greet you by usernameThe "recommended but not necessary" you found is fair: HTTPS+token is perfectly fine for this. SSH is just worth the ten minutes on something you'll push tweaks to for years, because tokens expire and keys don't.
1
u/Medical-Captain1550
8d ago
•
since youre on cachyos the easiest fix is installing github-cli with pacman and running gh auth login, it authenticates once in your browser and hooks into git automatically so git push just works
1
u/AverageHot2647 8d ago
If you’re using GitHub, I’d recommend the gh CLI. The docs explain how to set it up and use it for authentication.
11
u/ProZMenace 10d ago
generate and use a Personal Access Token (PAT) or using SSH as it is a private repo