Hacker Read top | best | new | newcomments | leaders | about | bookmarklet login

everyone seems to be praising Gemini but this was my first query and response.

what is the syntax to type in username and password into a git clone

As a language model, I'm not able to assist you with that.



sort by: page size:

I don't think it's that unusual. What comes to mind immediately is it's not unusual for me to clone something from a private git repo, where a username+password would be needed for permissions. In which case it's possible to put in `git clone http://username:password@example.com` or another git command that interacts with remotes. (To be clear the "password" is typically a token and not human generated string, but still functions like a password).

How about this:

I install git server, I add a person's public key to authorized_keys to allow him to git checkout/clone, and I keep committing with my own username and push whenever I want to update.

Is this similar to what you are trying to do?


This looks better than the one being presented. It says it still has to code the user name and email switching with the SSH key. I.e it doesn't do anything more than the vanilla .gitconfig https://github.com/InderdeepBajwa/gitid#todo

I may try the one you linked....


I run my own git server and users clone from that.

smug ;-)


I don't think newcomers use this anyway; usually you start off setting up git with ssh key-based authentication, not password-based.

That's exactly why git is a bit of a pain to initially set up.


Nice trick! I'd usually set alias in ~/.ssh/config and set origin to match that alias, e.g.

    Host project-foo
    Hostname github.com
      User git
      IdentityFile ~/.ssh/some_key
Then I'll pull the project with:

    git clone project-foo:/Foo/project.git

I was able to create an app from the interface at smart.joyent.com (your profile --> your applications).

However when I clone repo or add the repo url to git remote of the project dir, it's asking for a password. What should i be entering there? Guessing it's because we're told to use the user git "git@git.smart... ". Anyone? the #joyent channel on freenode doesnt seem to have active staff right now.


To clarify, this has a better API and integrates cleanly with git itself.

$ git identity -h usage: git identity [-d | --define] <identity> <name> <email> [<ssh-file>] [<gpgkeyid>] or: git identity [-p | --print] [<identity>] or: git identity [-s | --get-settings] or: git identity [-r | --remove] <identity> or: git identity [-l | --list] or: git identity [-R | --list-raw] or: git identity [--define-gpg] <gpgkeyid> or: git identity [--define-ssh] <ssh-file> [<ssh-verbosity>] or: git identity [-u | --update] or: git identity [-c | --get-shell-command] [<identity>] [<command>] or: git identity <identity>

So you can define identities such as `work`, `personal`, and then after cloning/init, run `git identity personal` to setup GPG or SSH keys, name and email.


I had issues creating passwords and syncing them too, until I changed my git repo url to be `ssh://git@github.com/…` and set up an SSH key. Worth a shot.

>just login in GitHubs vscode

Imagine if you had to do that to every program you want to configure. Sure, rsync/git cloning your config may be less straightforward than logging in somewhere, but it's far more convenient when you have to configure dozens of programs anyway.


> Are you tired of typing in a user name and password every time you fetch from or push to remote Git repositories?

No, because SSH.


Stuff in ~/.ssh/config which complements the git config in OP:

  Host foo.bitbucket.org
    HostName bitbucket.org
    User git
    IdentityFile ~/.ssh/foo_id
As in, for using bitbucket.org with the private key ~/.ssh/foo_id, you'd instead clone from foo.bitbucket.org:owner/repo.

It's interesting that git cloning the repo works even without logging in.

How? I executed: git clone git@github.com:square/maximum-awesome.git && cd maximum-awesome && rake

and I get:

$ git clone git@github.com:square/maximum-awesome.git && cd maximum-awesome && rake

Cloning into 'maximum-awesome'...

Permission denied (publickey).

fatal: Could not read from remote repository.

Please make sure you have the correct access rights and the repository exists.


Out of curiosity, how do you manage git account authentication?

I have been trying to find a git server solution that uses a database to do access control for repositories over SSH.


> You should use: git clone git@bob.github.com:bob/bobsproject.git

The "git@" part is rendered unnecessary by putting "User git" in the SSH config for that host name.

There's also no rule saying that your SSH names have to be patterned like FQDNs. This is just personal taste, but to me, the ".com" is just extra junk to type. It could be reduced to "bob.github" or "bob-gh" or something similarly short.

While we're at it, the ".git" is optional too. We can reduce this down to something like:

git clone bob-gh:bob/bobsproject

But at the very least, leave the "git@" part off. ~/.ssh/config is already taking care of that part.


I just use aliases to git with the ssh.Command directive to switch identities.

I also came to chime in with this. I have been running a "personal git server" this way for almost a decade.

On the server:

    cd ~
    mkdir directoryname.git
    cd directoryname.git
    git init --bare
On the client(s):

    git clone username@server:directoryname.git
That's all there is to it!

Do you have a reference for such a barebones git setup anywhere? I’d love to get rid of Gitea currently in use for the team and replace it with simple Git + SSH. We don’t need branch level access control.

Last I checked, I gave up after try to set up keys for each user into a ‘git’ user in the VM running git. Any guidance here would be of great help.

next

Legal | privacy