在Eclipse中向Debian VPS的Git远程仓库推送代码遇权限问题求助
Got it, let's get this push issue sorted out quickly. The root problem here is straightforward: the git:// protocol is read-only—it works perfectly for cloning or pulling code, but it doesn't support pushing changes because it has no way to handle authentication. Since you already have SSH access to your Debian VPS, we just need to switch your local repo's remote URL to use SSH instead, and make sure a few basics are set up on the server side.
Step 1: Confirm your VPS repo is a bare repository
First, SSH into your Debian VPS to check if your Git repo is set up correctly for pushes. Regular Git repos (with a working directory) don't allow pushes by default—you need a "bare" repo (no working files, just the Git metadata):
- Connect to your VPS via SSH:
ssh your-username@myWebsite.com - If your existing repo is a regular one (you see files like
README.mdalongside a.gitfolder), convert it to a bare repo with:git clone --bare /path/to/your/current/repo myRepository.git - This will create a new
myRepository.gitfolder (the bare repo) that's ready to accept pushes. Note its absolute path (e.g.,/home/your-username/myRepository.git).
Step 2: Update the remote URL in Eclipse
Now let's point your local Eclipse project to use the SSH URL instead of git://:
- Open your project in Eclipse, then open the Git Repositories view: Go to
Window > Show View > Other..., then selectGit > Git Repositories. - In the Git Repositories view, expand your project's repo, then expand
Remotes > origin. - Right-click on
originand select Properties (or Configure Push... depending on your Eclipse version). - In the URI field, replace
git://myWebsite.com/myRepository.gitwith your SSH URI, which follows this format:
For example:your-username@myWebsite.com:/path/to/your/bare/repo/myRepository.gitjane@myWebsite.com:/home/jane/myRepository.git - Save the changes.
Step 3: Test the push
Make a tiny test change to your code (like adding a comment to a file), stage and commit it as you normally would in Eclipse. Then try pushing again—Eclipse should prompt you for your VPS SSH password (if you haven't set up key-based auth). If all goes well, the push will succeed!
Bonus: Set up SSH key-based authentication (no more passwords!)
To make pushes even smoother, set up SSH keys so you don't have to enter your password every time:
- On your local machine, generate an SSH key if you don't already have one:
Just press Enter through all prompts (you can add a passphrase for extra security if you want).ssh-keygen -t ed25519 - Copy your public key to the VPS:
ssh-copy-id your-username@myWebsite.com - From now on, Eclipse will use your SSH key to authenticate automatically when pushing.
内容的提问来源于stack exchange,提问作者Errore Fatale

