Emerson Cod
Emerson Cod

Reputation: 2090

How to set the right user for github push

I have a github repository with a username - let's call it githubuser

I have a workstation again with a username - let's call it workstationuser

I cloned the repo on my machine and changed something. Now I want to push the changes to github, so that githubuser is the author.

But when I execute git push origin master I always get

remote: Permission to githubuser/your-repo.git denied to emersoncod.

I have no idea how and when this user emersoncod was set, I simply cannot get rid of that.

Where could this be configured ? How can I configure it that githubuser is pushing ?

Thanks for any help

Update

I checked the .git/config file inside my local checkout

[core]
    repositoryformatversion = 0
    filemode = true
    bare = false
    logallrefupdates = true
    ignorecase = true
    precomposeunicode = true
[remote "origin"]
    url = https://github.com/githubuser/your-repo.git
    fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
    remote = origin
    merge = refs/heads/master
[user]
    name = githubuser
    email = [email protected]

Update 2

And the .gitconfig file in my home directory

[user]
    name = githubuser
    email = [email protected]

Upvotes: 1

Views: 229

Answers (3)

Emerson Cod
Emerson Cod

Reputation: 2090

Ok I found it out myself.

I changed the git/config file to

url = [email protected]:githubuser/your-repo.git

so from https to ssh and with that it works.

Upvotes: 1

CodeWizard
CodeWizard

Reputation: 141946

It can be one of several reasons:

The user is not contributor to the github project

  1. Navigate to the repository on Github you wish to share with your collaborator.
  2. Click on the Settings link in the right side menu, below Network
  3. On the new page, click the Collaborators menu item on the left side of the page.
  4. Start typing the new collaborator's GitHub username into the text box.
  5. Select the GitHub user from the list that appears below the text box.
  6. Click the Add button.

Read this out: http://readwrite.com/2013/10/02/github-for-beginners-part-2


Working with ssh

You have to define new keys for the user

Simply follow those steps and you will set up your ssh key in no time:

  • Generate a new ssh key (or skip this step if you already have a key)
    ssh-keygen -t rsa -C "your@email"

  • Once you have your key set in home/.ssh directory (or Users/<your user>.ssh under windows), open it and copy the content


How to add sh key to github account?

  • Login to github account
  • Click on the rancher on the top right (Settings)
    github account settigns
  • Click on the SSH keys
    ssh key section
  • Click on the Add ssh key
    Add ssh key
  • Paste your key and save

And you all set to go :-)

Upvotes: 3

user376507
user376507

Reputation: 2066

From your repository within GitHub, navigate to the settings screen from the list menu on the right side of the browser. From the settings go to the collaborators section using the link on the left side of the screen. Add your local username (workstationuser) to the list of collaborators and you will be able to push to the repo.

You can use the method mentioned by @Tgsmith61591 to set your username in local repository.

Upvotes: 0

Related Questions