新成员更换工作站后无法向Bitbucket共享仓库推送Git提交
Hey folks, let's tackle this Git push error your team member is facing! That policy block usually boils down to mismatched user credentials or commit author info on the new workstation—super common when switching machines. Here's how to fix it:
1. Check & Correct Git User Configuration
First up, confirm what user details Git is using on the new machine. Run this in the repo directory:
git config --list | grep user
Look for user.name and user.email—these need to match exactly the credentials that worked on their old workstation (the ones linked to your team's repo permissions).
If they're wrong, set the global config (applies to all repos on the machine):
git config --global user.name "Their Full Name" git config --global user.email "their-work-email@company.com"
If only this repo needs a specific config, skip the --global flag and run the commands inside the repo folder.
2. Fix Existing Commits with Incorrect Author Info
If they already made commits using the wrong user info, the repo policy will flag those as "other users' commits." To fix this:
- Figure out how many recent commits need updating. For example, to edit the last 2 commits:
git rebase -i HEAD~2
- In the text editor that pops up, change
picktoeditnext to each commit that needs fixing. Save and close the editor. - For each commit that comes up for editing, run this to update the author:
git commit --amend --author="Their Full Name <their-work-email@company.com>" --no-edit
- Move to the next commit with:
git rebase --continue
Repeat steps 3-4 until all problematic commits are fixed.
3. Verify Authentication Setup
Double-check that the new workstation is properly authenticated to the repo:
- SSH: Make sure the new workstation's SSH public key is added to their account on your Git platform (like GitLab/GitHub). If they don't have a key, generate one with
ssh-keygenand add the public key to their account settings. - HTTPS: If using HTTPS, ensure Git isn't caching someone else's credentials. Clear the cache:
- Windows: Open Credential Manager, find entries for your Git repo, and delete them.
- Mac: Run
git credential-osxkeychain eraseand follow the prompts. - Linux: Use
git credential-cache exitto clear the cache, or adjust your credential helper settings if needed.
Once all these checks are done, have them try pushing again:
git push --set-upstream origin Branch
内容的提问来源于stack exchange,提问作者Ryan

