I was logged previously on different account and then successfully logged out of github and logged in to my main account.
But the problem is: when I set up origin, branch, etc it pushes the commits using the credentials that I was logged in as previously.
I tried removing credentials in control panel a few times, restarting the PC and using commands to set github username and github email so they correspond to my main account. Unfortunately, it didn't work.
Every time when I remove the credentials, a windows pops up after the command git push -u origin main
Then I log in to my main account and push some changes, but the commits are not credited to my main account (which it's supposed to be), but instead commits are shown as having been done by the account that I was previously logged in to.
But the commits are not credited to my main account
"Main account" is about authentication (the username/password you enter in the credentials popup)
"commits are about authorship (see the output of git config user.name/git config user.email)
If it a local configuration of your repository (in myrepo/.git/config) that you will find the user name/email used when you create new commits.
Related
I am fairly new to GitHub (2 days only). I created a repository and added two close friends to collaborate. When I push/pull to GitHub using terminal it works perfectly
However, when they try to do it they are asked for a username and password. If they enter their username and password it does not work; but if they enter mine it works.
How can I overcome this?
The documentation "Inviting collaborators to a personal repository" includes:
The user will receive an email inviting them to the repository.
Once they accept your invitation, they will have collaborator access to your repository.
So make sure they have received and accepted the invitation.
Otherwise, their credentials would not give them write access to your repository.
I have a GitHub account, and I created a new one (temporary, not to replace the old one).
Now, I try to go back to my old account, I changed the email with git config --global user.email = "myuser#email.com" tried to push to an old repo I have connected to my old account, and It says "Permission to X denied to NEW_GITHUB_NAME"
What do I need to do to get back my old account?
So I have a personal and a work's Github account.
After some trial and error I found that the password to Github is stored in the macOS keychain.
That's annoying cause I can't define which account to associate the repo with even though I'd configured my user in ./git/config for that repo.
And the reason it seems is that git will start searching for the global config first. So I removed the global config and keychain and pushed again.
It prompts me for the username password the first time, but stores that into the keychain again and uses that as the default user, not respecting the user I set in ./git/config.
My ideal setup is to have the default user as my personal account and to have the work's account for specific work related repos. How do I do that?
I think the keychain is a bottleneck since it seems to be the first place git is using as authentication.
I found the answer, here
git config credential.username 'your username'
This causes the cli to prompt for a password for that user and it will store that as another entry in the keychain. Will still have to configure git users with git config user.name etc so it knows which user to use.
We recently moved our github from one account owner to another, and now all of the sudden when I do a git pull or any git command on the remote repo, it asks me for github username and password.
My git-config says:
[github]
user = kamilski81
token = *********
Any idea how I can stop it asking me for credentials and remember everything, does the new owner have to setup my ssh keys or something of that sort?
Following this article sorted it out for me:
https://help.github.com/articles/why-is-git-always-asking-for-my-password
git remote set-url origin git#github.com:user/repo.git
The github username and token in the gitconfig is only used for interactions with the GitHub API (for instance the hub gem and the github tool).
If you are pushing and pulling from a GitHub repository over https, then you need to specify your credentials every time, or hook into a password manager to remember the credentials for you. How to do this depends on your platform.
The easiest thing to do is to go to your github account and submit your SSH public key to your account, and then switch your github remote to push/pull over ssh instead of https.
[edit] After re-reading the question I noticed that you mentioned it was previously a GitHub repo that was just moved from one owner to another. If that's the case, and you ARE able to push and pull by specifying your credentials, it sounds to me to be one of two scenarios:
The previous remote used ssh, and GitHub has your SSH key; but when the owner changed and you updated the remote, you updated it to go over https.
The previous remote used https, but you had a password manager setup correctly to deal with your credentials, which no longer works.
After doing "remote -v"....the issue was that my remote was using an "https" remote rather than "git" remote. Changing the remote to use git rather than https solved everything.
If you execute only once git pull and Git client still asking you the credential without do the git pull for you, the problem should be because your credential is incorrect or not setup yet.
but if you get the dialog ask for credential one for each operation, it mean that your credential isn't remembered. To do that, you may use Pageant to store your SSH private key, so, everytime you do something, it will retrieve your credential from Pageant instead to asking you.
I have a TeamCity continuous build process setup for a personal GitHub project which works well. However, in TeamCity I want to see a list of commits under "My Changes" (http://teamcity/changes.html).
Under "VCS Username Settings" (http://teamcity/vcsSettings.html) I have set the username as "benpowell" to match my Github account and as you can see all commits are logged under that name. However, none of the commits are logged under "My Changes".
Any ideas why?
One note that might help is that TeamCity has a "Username style" setting under the VCS root itself. For a new installation of TeamCity 9.0.1, it defaulted to just "Userid". I had to go in and change it to "Author Email". Note - this setting is hidden under "advanced options".
Per the screen, it will only affect newly collected changes from source.
Once this is done, you should be able to use email addresses under VCS Username successfully.
See the screenshot for more details on this setting:
To find the correct VCS username open up TeamCity and view your build. Under Recent History you'll see a column that is called Changes, which links to the commit/push that triggered the build (if you have continuous integration setup).
The username is shown there as seen below in the :
Notably, the username does appear to be linked to my email address. It is the username part of my Gmail address. I'm assuming Github extracted that, because I wouldn't have chosen that username personally.
I had a similar problem and found this post helpful. There are three things that determine the user bindings between your commits to git and build information in TeamCity:
Setting the correct git identity in your local clone (i.e. git config user.name, and also user.email). This is how git stamps your commits.
Establishing the mapping between your git identity and your TeamCity identity. This is done by setting the UserName Style in the advanced settings of your VCS roots.
Setting the default username in the Version Control Username Settings in your TeamCity user profile. This is the value that will be used as the lookup key by the mapping you specified in #2.
So, for example, assume a user has a local clone git identity of user.name JCoder and user.email joe.coder#foo.com (#1 above), and UserName Style of UserId (#2) above, and a TeamCity account with the Name Joseph Coder and Version Control Username Setting of joe.coder (#3) above.
TeamCity will correctly attribute this user's changes (in build history, for example) to the TeamCity user Joseph Coder. This is because the UserName Style of UserId maps between git and TeamCity users by using the email prefix of user.email, joe.coder in this case. Note that there are several Username Styles (mapping styles). I stick with UserId because it uses the email address which is typically the most stable identifier.
With GitHub you need to add the email address used in the commits to your GitHub account for it to see them as your commits.