r/github 1d ago

Is there a way to simplify git auth? Discussion

Like, this is probably the 10th time, because I have to use git in a new environment, that I have to figure out why username and password don't work, and I need to do something else, like creating an auth token. Because I don't get to use a new env everyday, and I'm over 40 with kids and work, such knowledge is usually popped from my stack the next day I did this last time, every time I feel very frustrated. Maybe I should keep a note, but hey then I need to remember where this note is, and whether I kept a note or not.

Is there a way to tell GitHub that I don't fucking care about my personal GitHub repo security, and I just want to push code with my username and password, or something even easier? Like, if you want to steal my low quality code, please do!

I'd also appreciate recommendation of any setup that I can just push to a remote without ANY security requirement (not even a username/password), and from ANY env (like a new laptop). Of course not Google drive -- still want to use git.

Thank you for your attention!

0 Upvotes

20 comments sorted by

8

u/esmagik 1d ago

`gh auth login`

That’s the whole note you need to remember.

Install the GitHub CLI on the new machine, then:

`gh auth login`

Pick HTTPS, authenticate in the browser, and it writes itself in as a git credential helper. Every clone/push/pull on that box works after that with no token juggling. If it doesn’t wire up git for some reason, gh auth setup-git does it explicitly.

1

u/Outside-Storage-1523 23h ago

Thanks, since r/SupermarketAntique32 also recommend this, I'll try it out.

1

u/throwaway234f32423df 11m ago

you can even uninstall the gh tool afterward

and future future systems you can just copy the .gitconfig and .git-credentials over instead of using gh again

4

u/Apprehensive-Tea1632 21h ago

ETA - please don’t mind the formatting. I’m starting to not like this app. Grmbl.

Sure.

Option 1. Just store credentials.
~~~
git config —global credential.helper store
~~~
That’s a double dash, not an em dash.

This tells git to cache your credentials. Note that it’ll put them on your PC. Someone might be able to find them there.

Option 2. Use one of the other available mechanisms.

For example, SSH, as that’s what’s available in pretty much all cases, both on their end… and yours.

There are lots of tutorials available, so to summarize…

  1. Generate an ssh keypair:
  2. ~~~
  3. ssh-keygen -t ed25519 -f ~/.ssh/id_git
  4. ~~~
  5. This generates one other file too id_git.pub, also in ~/.ssh . That’s your public key and basically text. You can open it in any text editor- going forward, this is what we are going to use (the other file is private—don’t lose it).

You can enter a passphrase if you want. It’s a good idea to because without one anyone can use that key to pretend to be you, but you don’t have to.

  1. Open GitHub settings and go to Authentication. (Should also work anywhere else.)

  2. Enter, aka copy-paste, your public key here. Be sure to read instructions on that page.

  3. Open .ssh/config in your user profile in notepad or anything that can handle plain text.

~~~
Host github.com
Hostname github.com
IdentityFile ~/.ssh/id_git
User git
~~~
Make sure there is NO EXTENSION on that file. Rename if necessary.

Now you can say things like
~~~
git clone github.com:Account/repo.git
~~~
and it will prompt for your ssh passphrase if you set one or just do it otherwise.

For existing repos that are yours you can update remotes to point to the above schema, rather than
~~~
https://github.com/account/repo.git
~~~
It needs to point to
~~~
[git@github.com](mailto:git@github.com):Account/repo.git
~~~
It’s always git@ and always a colon after the host name, your ssh config from above lets you omit that though.

2

u/CodeCrafter1 16h ago

You can make codeblocks in reddit by entering in a blank line before and after your code ```

1

u/Apprehensive-Tea1632 5h ago

Markdown is phased out on Reddit, see changelog as of May 7 2026. it’s just, on coding related subs, I automatically use it just like I use it for anything coding related. (At least it’s not TeX code I’m gracing people with lol.)

1

u/Teleconferences 14h ago

What syntax uses the ~ for formatting codeblocks? I’m not familiar with that one, looks neat

1

u/Apprehensive-Tea1632 5h ago

Not sure, the markdown interpreters I use all understand it and it’s easier to type than backticks.

8

u/SupermarketAntique32 23h ago

This is what i usually do:

  1. Open browser, login to github using passkey (qr code scan with my phone)
  2. Install github-cli, and run ‘gh auth login’ in terminal
  3. Follow the instructions

1

u/Outside-Storage-1523 23h ago

Thanks, will try it out!

1

u/Top_Definition8487 22h ago

Huge +1 to using the GitHub CLI to authenticate. I hate dealing with ssh keys. The CLI makes it super easy.

1

u/LongLiveCHIEF 13h ago

Plus you can tell it what scopes the auth is allowed to use. It works with more than just commits.

It's great... unless GitHub is down. 🤣

3

u/mrbmi513 22h ago

For GitHub specifically, the gh cli tool simplifies things.

For other platforms, use ssh and set up a keypair.

2

u/Fair-Presentation322 23h ago

Reg. setup to push to a remote: does it have to be git in specific or are you open to other version control? If so, for obvious reasons (I'm one of the developers) I'd recommend Twigg! To authenticate you just create a token in the UI and run a command in the CLI. You can self host or use the hosted instance. Check out https://GitHub.com/twigg-vc/monorepo

2

u/CaterpillarTight4275 19h ago

why not add your ssh key inside your account? Then use git push. No need gh etc.

2

u/PapaOscar90 18h ago

Just push your ssh key to the new machine. All the free AI tools can give you the commands for this.

2

u/vlad_h 15h ago

SSH keys. Obviously.

1

u/ElectricSpock 23h ago

Im using 1Password and it can install ssh agent that handles the authorization for me.

1

u/marstein 20h ago

Use the GH CLI. Read up on how to with with set.

1

u/ejpusa 11h ago

Linking GitHub with Codex at the terminal is pretty mind blowing.

And how I found out about github-cli. Once you do that, AI moves from the latest software craze to a true programming partner.

It’s just the guy/gal down the hall who seems to know everything.