I am trying to figure out where to store my personal access token (PAT) generate in GitLab on a remote Windows 10 environment to authenticate on that GitLab instance.
Assuming I already have a local git repo on a shared drive, I can log in to my environment as myself, authenticate and set my remote like this:
git remote set-url https://{my username}:{my access token}#{repo name}.git
This provides authentication for me and when I commit and push I am properly identified in the gitlab instance.
However, if I log out and a colleague logs in and comes into the same repo on the same shared drive the remote will be authenticated for me rather than them. That is the remote will look like this:
git remote -v
> origin https://{my username}:{my access token}#{repo name}.git (fetch)
> origin https://{my username}:{my access token}#{repo name}.git (push)
This isn't any good because my colleague has to either a) reset the git remote anytime they want to use the remote or b) authenticate with my PAT. Can anyone recommend a way to store ones username and PAT such that the remote looks more like this:
git remote -v
> origin https://{repo name}.git (fetch)
> origin https://{repo name}.git (push)
Related
Prefacing this with I am very new to git and github.
I set up a repo on github, as user zzz, and it is correctly listed in my local (repo-specific) git config file, which has entries like the following when I do 'git config --local --list':
remote.origin.url=https://github.com/zzz/myrepo.git
user.name=zzz
user.email=yyy#example.com
But when I do do git push origin master, it get 403 denied to user 'xxx'... a user which corresponds to a completely separate github account. How do I fix this? And why is it picking up user 'xxx' when that is not the user i carefully specified in the local config file? I am on windows 7 machine.
Git store credentials in Windows, clear them referring below image:
Run your git push command, it will prompt you to enter credentials again.
Image Courtesy - Remove credentials from Git
I am not very familiar with Github.
I changed my username on the web client due to security issues.
I had an Xcode project that I was committing locally and pushing to remote.
I want to push to the same remote but can't since the username is now changed. How do I modify this in Xcode/terminal?
I also want to change the local username to the same one I have on the remote. How/where can I change this
I tried checkout out one of my own GitHub projects (it's public and not that interesting but I'll use it as the example anyway).
When I go to the command line and perform git remote -v I am told:
machine:Clock-Signal user$ git remote -v
origin https://github.com/TomHarte/Clock-Signal.git (fetch)
origin https://github.com/TomHarte/Clock-Signal.git (push)
Supposing I were to change my username to HarteTom then the new remote location of my repository would become:
https://github.com/HarteTom/Clock-Signal.git
Noting that both of those locations are named as 'origin' from the first output I could perform git remote set-url origin https://github.com/HarteTom/Clock-Signal.git. I could confirm that with another git remote -v which would now say:
machine:Clock-Signal user$ git remote -v
origin https://github.com/HarteTom/Clock-Signal.git (fetch)
origin https://github.com/HarteTom/Clock-Signal.git (push)
I used my old github account and now that is deactivated and i have a new one now. I want it to communicate with my new github username. I've tried many internet solutions and re-installing git and the command line tools. Whenever i type in git remote -v
origin https://github.com/OldUsername/App.git (fetch)
origin https://github.com/OldUsername/App.git (push)
This account is now deactivated so there is no way to use it, I've tried doing the
git config --global user.email "YOUR EMAIL ADDRESS"
git config user.name "Username"
I've been trying for hours and still can't figure out how to get my command line to be able to push to new projects under my new username.
That's the push setting for the remote in your repository config.
Either go hand edit /.git/config or try something like
git remote set-url origin https://github.com/NewUsername/app.git
Remotes are part of a local repository. You can add, remove, rename, or reconfigure them with various git-remote subcommands. You might consider just nuking the current repository directory if it doesn't contain anything you value and cloning or creating a new one.
Alternatively, you can set the URL for a remote using:
git remote set-url origin <new URL>
I am on Mac OSX, git version 1.8.5.2 (Apple Git-48)
I had a git submodule in a git repo that had (to my knowledge) only ever been cloned, pulled, committed, merged and pushed using one git user and rsa key. I have many other pairs of users and keys but no others were specified in the ~/.gitconfig file.
When this submodule had the remote of https://github... etc. It would allow me to commit with the correct username and email being applied but when pushing, would tell me that:
remote: Permission to some_username/project.git denied to user2.
fatal: unable to access 'https://github.com/some_username/project.git/': The requested URL returned error: 403
However when I removed the https://... remote and instead used the git#github.com:some_username/project.git remote, it works correctly.
Is this a bug with git or github? Was there any other way to fix it? Both these users have their associated rsa keys associated on their github accounts.
Is this a bug with git or github?
No: with https url, you need to add the login in the url for git to know what credential to ask for:
cd /path/to /your/submodule
git remote set-url origin https://yourLogin#github.com/yourLogin/yourRepo
An ssh url would use automatically your key (in $HOME/.ssh/id_rsa.pub) which, if published to your account (and if your account is the owner or collaborator of the GitHub repo)
I have read some questions around but still didn't found the solution to this problem
I have git on windows and I want to connect to github using ssh.
Following this tutorial https://help.github.com/articles/generating-ssh-keys
I have successfully setup my keys
If I open a git-bash and try to ssh github I am able to connect, so this works
ssh -T git#github.com
Hi username! You've successfully authenticated, but GitHub does not
provide shell access.
this means that git-bash actually sees my keys. However if I try to do a push
git push origin master
git prompts me for username and password
Thank you for your help
EDIT: solved by using the git protocol instead of the http protocol, my fault
so replace this
https://github.com/_user_/_repository_.git
whit this
git#github.com:_user_/_repository_.git
in the remote link
No need to remove/add, just do something like this:
git remote set-url origin git#github.com:username/repo.git
You probably cloned a remote that uses the https protocol, rather than the git protocol. You need to redefine your remote for origin.
# Change this as needed.
github_username="$LOGNAME"
# Replace your remote, then push.
git remote rm origin
git remote add origin "git#github.com:${github_username}/${PWD##*/}.git"
git push --tags --set-upstream origin master