Reputation: 551
I just started using git in combination with bitbucket.org and egit (eclipse git plugin) for a home-project. I never used git before (for university projects I only used SVN), so I wanted to learn more about git. I successfully created and cloned a bitbucket repository to my laptop and desktop pc and committed some changes to the local repositories. I made some changes on my laptop and my desktop PC, which I know would result in a conflict while merging. So I pushed the first changes from my laptop to bitbucket and expected that git would inform me about the conflicts when I try to push things from my desktop pc. When I now try to push changes from my desktop pc to bitbucket, it says that my push was rejected (it does not say why it rejects it). If I try to fetch something from bitbucket to my desktop pc, I have to choose a destination ref. This is kind of strange to me, since I want to fetch the changes in the bitbucket repository into my local repository on my desktop pc.
I read some little tutorials about git and mostly configured egit by hand, so I might messed up the configuration or maybe I am using a wrong workflow here.
Any ideas where I could start to find out, whats going on here?
Upvotes: 1
Views: 683
Reputation: 51935
This is a rather annoying bug in Egit, which won't properly configure the remote when you add it using Egit. I've seen some of the tutorials and blog entries out there, but they're not always helpful (and sometimes just wrong).
To fix this, the easiest way is probably to actually use Git to add the remote. To do this (and assuming you have installed Git), open a terminal windows, and navigate to your repo on the machine where fetching doesn't work.
In the repo, do
git remote remove origin
git remote add origin [email protected]:USER/REPO.git
In these commands, origin
is a local name to identify that remote; you can choose it freely (it must be unique in that local repo), but in the deletion command that must be the name of the remote which currently exists in your repo, of course.
Replace the bits USER
and REPO
with your bitbucket username and repo name, respectively.
This uses the SSH url, which assumes you have registered your SSH key with bitbucket. If you want to use the HTTPS url instead, you can simply use that in the addition command (you can get the complete url from the repo page on bitbucket).
Using Git to add the remote (instead of Egit), will make the required settings for the remote to work; you should then be able to push and fetch/pull, both using Git and using Egit.
Technical details note: Egit does not set up a default refspec when adding a remote (or when adding a remote for pushing, it does not set up the refspec for fetching). Instead it asks the user to enter a refspec when fetching for the first time (this is the same dialog as where it asked you ref name), without even suggesting a sane default.
When adding a remote with Git, the push and fetch refspecs are set to the default value which works for the overwhelming majority of use cases.
Upvotes: 1