git push problem: committer'x x x (x)'does not match your user account

Keywords: Programming git ssh github Google

Written in front

When you use multiple git accounts locally, or when multiple people deploy multiple git accounts with one machine, there are often conflicts. Today, you have encountered one.

Problem description

Many of us use a machine together. When we reconfigured yesterday, we accidentally set my username and mailbox to the global configuration. As a result, when others use it today, we can't push it. The following error message is prompted:

committer 'pearl (pearl@myemail.com)' does not match your user account.
the following user name and email address is currently registered.
other (other@heremail.com)

Baidu google has been checking this issue for a long time, and it is not good to reset ssh key. It still keeps reporting errors and executes them according to git's error prompt.

git commit --amend --reset-author

Still can't solve the problem. Later, I studied his error message with my friend. It showed that committer was incorrect. Then git log checked the log and found that there was information submitted by my user name in the log. So I decided to roll back and see it, and then executed it.

Git reset -- hard logID (log ID before I submitted)

Set ssh key again and git push again.

Summary of problems

The reason for this error prompt is that git commit was submitted by an unauthorized user. Although ssh key was reset later, the previous submission was not revoked, so git push would make an error. The solution is to revoke the previous submission, that is, to roll back to the last submission that raised the problem, and then reset the GIT information, and resubmit it.

Setting up multiple SSH keys

  • Do not set global usernames and mailboxes. Set user information under the corresponding git project

    git config user.name "your_username"
    git config user.email "your_email@example.com"
  • Generating ssh key

    ssh-keygen -t rsa -C "your_email@example.com"
    
    # When you see the following prompts, enter the file name of ssh key, such as id_rsa_username
    Generating public/private rsa key pair.
    Enter file in which to save the key (/your_home_path/.ssh/id_rsa):id_rsa_username

    Then you can see two newly generated files in the current directory, one id_rsa_username and one id_rsa_username.pub.

  • Add ssh key to your git project (such as github)

    cat id_rsa_username.pub

    Paste the above to the ssh key settings in the git project

  • Add the newly generated key to ssh-agent

    eval "$(ssh-agent -s)"
    Agent pid 59566
    
    cp id_rsa_username ~/.ssh/
    cp id_rsa_username.pub ~/.ssh/
    ssh-add ~/.ssh/id_rsa
  • Set up the configuration file without adding it every time

    cd ~/.ssh
    vim config
    
    # This file is used to configure the server corresponding to the private key
    # Default github user(first@mail.com)
    Host github.com
    HostName github.com
    User username1
    IdentityFile ~/.ssh/id_rsa_username1
    
    # second user(second@mail.com)
    # Create a github alias and use it to clone and update new accounts
    Host github2
    HostName github.com
    User username2
    IdentityFile ~/.ssh/id_rsa_username2

Common Git commands are attached (see: Quick Look-up Table of Common Commands in git)

View a help document for a git command
git help [command]
View the status of individual files
git status
clone A Warehouse
git clone [url]
Initialize a warehouse
git init
Pull out
git pull
Add to
git add [file]
Submission
git commit -m "commit info"
Delete files (from temporary and workspace)
git rm [file]
Force deletion of modified files (from temporary and workspace)
git rm -f [file]
Delete files (delete from the temporary area, i.e. cancel commit before commit)
git rm --cached [file]
Moving files or modifying file names
git mv [old-name] [new-name]
View local branch information
git branch
View remote branch information
git branch -r
View all branch information (including local and remote branches)
git branch -a
Create branch
git branch [branch_name]
Switching branches
git checkout [branch_name]
Merge branches to current branches
git maege [branch_name]
Delete branches that have been merged
git branch -d [branch-name]
Delete branches that have not yet been merged
git branch -D [branch_name]
Merge code has not yet been submitted, at which point you want to undo the merge
git reset --hard HEAD
git reset --hard log_id(Roll back to a specified log position)
View the submission log
git log
View the submission log and its corresponding diff
git log -p
View the submission log and the files involved, and how many rows these files have been deleted / added
git log --stat
diff Displaying Files in Temporary Zone
git diff --cached
diff Displays Files Not Put in Temporary Zone
git diff [file]
Export diff to development file
git diff > diff.txt
View the current branch and a branch diff
git diff [branch_name]
View the difference between a directory in the current working directory and a branch
Modify last submission
git commit --amend
Revoke documents that have been temporarily deposited
git reset HEAD [file]
Revoke modifications to documents
git checkout -- [file_name]
View the currently configured remote warehouse
git remote
View the currently configured remote warehouse and its corresponding address
git remote -v
Add remote warehouse
git remote add [remote_name] [url]
Grab data from a remote warehouse
git fetch [remote_name] [branch_name]
Push data to remote warehouse
git push [remote_name] [branch_name]
View a remote warehouse information
git remote show [remote_name]
Rename remote warehouse
git remote rename [old_name] [new_name]
Delete a remote warehouse
git remote rm [remote_name]
Display existing labels
git tag
Search for specific tag s
git tag -l [keyword]
Create lightweight labels
git tag [tag_name]
Create tags with annotations
git tag -a [tag_name] -m [msg]
Label a previous submission
git tag -a [tag_name] [hash]
View information about a label
git show [tag_name]
Push labels to remote warehouses
git push [remote_name] [tag_name]
Push all local labels to remote warehouse at one time
git push [remote_name] --tags
Derive branch b into branch a
git checkout b
git rebase a
Before switching to another branch, if you don't want to commit changes on the current branch, you can use the storage function.
git stash
Display all storage
git stash list
Apply your storage
git stash apply [stash_name]
Reduction storage
git stash pop

Posted by nads1982 on Mon, 31 Dec 2018 08:09:08 -0800