pull from non local git repository using Egit - eclipse

I am trying to do a "pull" from my git repository on bitbucket, using Egit (Eclipse). I can do "push" without any problems, but when I try to pull I get the error message:
The current branch is not configured for pull No value for key
branch.master.merge found in configuration
I have tried creating new branches from both eclipse and bitbucket, but the can't seem to "communicate". When I create a new branch in eclipse, it's automatically a local ( which it shouldn't be)
How can I set up my eclipse and bitbucket for "pulls" (not local)?
(I am a bit confused as I thought I was connected to the repository, since push works)
Any help will be greatly appreciated

You need to specify an upstream branch.
The push works because of the default push policy "simple".
With Egit:
Access "Configure Branch":
Go to "Git Repositories" view,
Expand the branches, local
Then:
Right-click your checked-out local branch that can't pull
Select "Configure Branch...":
For "Upstream Branch:", put "refs/heads/yourBranch"
For "Remote:", put "origin"
Leave "Rebase" unchecked
Hit OK

Related

How do you get files updated from a GIT repository in eclipse?

I have successfully checked out a project from GIT hub but since then changes have been made to the repository. When I right click to team the PULL option is grayed out, when I fetch from upstream it says the files are up to date, but that is not true. I can verify this by visually comparing the file on my computer to the file at GIT hub. Is there any way to resolve this problem other than switching back to subversion?
You need to merge the fetch upstream into your branch to get the updated repository.
Or, you can use terminal
git pull origin master
Check this git pull docs
Also, Pull option is graved out because egit requires the branches to be set up for pull for the option to be available.

How to convert a remote branch into a local one in Eclipse using Bitbucket?

I'm kind a newbie on Bitbucket so I have a lot of doubts.
I share an Eclipse project between two different computers. I have pushed the project from one computer to the Bitbucket repository using the Eclipse plug-in. Now when I go to the other computer I have fetched the repository that is saved on Bitbucket, and it has created a new remote tracking branch on my Eclipse local repository.
My problem comes when I want to merge that branch with the local branch, I have no idea how can I do that
Anyone could help me?
ps: sorry if the problem or the situation is not very clear
You should follow the section "Pulling New Changes from Upstream Branch ":
a git pull is a fetch + a merge.
Right-click on a project in the Package Explorer and select Team > Pull or right-click on a repository in the Git Repositories view and select Pull to pull new changes from the upstream branch your local branch is tracking.
The section "Fetch and Pull" of the Egit tutorial says as much:
When cloning remote repositories, Git creates copies of the branches as local branches and as remote branches.
A Fetch operation will update the remote branches only.
To update your local branches as well, you will have to perform a Merge operation after fetching.

How do I get my new eclipse branch to show up as a new project in my github repository?

I am working through a programming book and I want to branch off of master for each chapter, then merge back to master once the chapter is completed, but have the chapter specific branch show up in my github permanently. What is the best way to do this through the eclipse gui? I have already created the branch in eclipse, but I can't get it to create the duplicate project branch in github.
Github repository
-master
-chapter1
-chapter2
If your "Team => Push to Upstream" is grayed, you need to specify the upstream address of your local Git repo in your Eclipse Egit configuration: see "Eclipse/Egit, Push to Remote menu choice is grayed out".
Check also your SSH2 config in the same EGit.
Finally, click on "Add all branches spec" in order to push all your local branches to the upstream repo:
Did you push the branch?
git push origin chapter1
git push origin chapter2
...etc...
(Note: If you're using a graphical interface for git in eclipse you might consider adding that information to the question.)

Getting started with GitHub and Eclipse (spring source toolsuite 2.7.1)

I am new with both Git and GitHub so please bear with me.
I have an empty repository on GitHub with an automatically created branch (gh-pages), which, I understand, is supposed to be used with GitHub's pages functionality.
Now what I would like to do is to create and eclipse project from which I could commit/push to this repository.
What is confusing me that I can't see any option to create a remote branch on github. I suppose pushing my source to gh-pages won't be a good idea. BTW, I also don't understand why the GitHub pages is feature is implemented as a branch? Aren't branches supposed to be merged with each other at some point. Clearly it wouldn't make any sense to merge github pages into my project. Wouldn't it be better to have a folder within my project for this purpose.
I googled and found this link but being a git noob I am not sure if that's what I want to do. I would like to use Eclipse as my primary interface to git and github only falling back to command line or other interfaces when there is no other option.
OK I think I have figured it out. Basically, what you need is to define a remote ref that need not exist before hand.
Create a project
Team->Share it to a local repository
In the repository view (Window->Show View-> Git -> Repositories) select the local repository and right click on remotes
Select new remote (configure push). Type origin in the remote name. Press OK
Change URL. Copy/paste the ssh uri from github. Select ssh protocol (make sure you have ssh key defined in eclipse SSH preferences, and uploaded to github)
Now the last part is to add Ref mapping. Click on Add.. in ref mapping section of screen. And enter refs/heads/master in both local and remote branches.
Or may be the refs/heads/master on both side isn't a good idea :)
I see, cloning a github repo that doesn't have gh-pages branch is simpler as it automatically creates this remote fetch spec
Remote Fetch Specification +refs/heads/*:refs/remotes/origin/*
Maybe this is what I need to enter in the step 6 above
Ok as it turned out the original idea of "refs/heads/master in both local and remote branch" was correct. Pushing with this configuration is showing my changes in git hub correctly. The second option on the other hand is failing silently.
Branches typically are used in the way you described, but nothing says they must be used that way. This is just the way github chose to let you manage your page content, and it works quite well. It's kind of similar to hosting multiple repos on one SVN server.
As for creating new repos, if you create a repo in github and then clone it, you'll have an empty repo locally that already points to github with a remote named "origin". This is a convenient way to start out, since you don't have to mess with adding a remote yourself. At this point, your repo has no commits and no branches in it. When you make the first commit, it will automatically establish a branch named "master". I don't know how eclipse is set up by default, but from the command line with default settings, you have to explicitly push new branches to a remote or else they won't get pushed at all. I.e. making the first commit and doing git push will just fail with a message like "No refs in common and none specified; doing nothing". Instead, you have to git push origin master to tell it to establish the "master" branch in remote "origin" (aka github). Thereafter, just a git push will work fine.
Hope that clears up some of your confusion.

EGit Local vs. Remote repositories

I'm new to git and am wrapping my head around how I'm supposed to be using git and egit. From the egit tutorial, I have setup a respository on GitHub, pushed my Eclipse projects to the remote GitHub repository from my local workspace, I can push changes to GitHub, switch branches, see the updates on GitHub, etc. This all makes sense.
Looking at the Git Repository explorer, I have a listing of "Local" branches and have no "Remote Tracking" branches and I have no "Remotes" listed. When I create a branch from a local branch, the egit dialog indicates "You are creating a branch based on a local branch" and suggests that I should be making a branch from a remote tracking branch.
So my question is, am I correctly using egit?
Should I just continue pushing changes to the remote GitHub repository? If so, what happens once I share the project and other developers clone the repository and start making changes to the remote repository?
Or should I now ditch the local repository and setup a new remote repository by cloning the existing GitHub repository that I initially created from my workspace?
Or do I create a new Push and Fetch "Remote" for my existing git repository?
Or something else?
Confused.
Since you created the repo on your local system and then pushed it to github without creating a remote you don't have a remote at hand. A remote is simply a short alias for the remote repository's URL. To fix this create a remote and a push and fetch configuration from the repositories view. In order to populate remote tracking branches in your local repo you need to run fetch once. As soon as this is done you can use "Push to upstream" instead of the more complex Team > Push... dialog which allows to define all parameters on the fly. When using native git command line you'll find the same concepts implemented there:
with
"$ git push [url] [refspec]" (e.g. "$ git push https://github/user/myrepo.git master:master")
you pass all parameters explicitly, this is similar to Team > Push... in EGit
with
"$ git push [remote]" (e.g. "$ git push origin")
you push to the repository defined by the configuration parameters of the given remote (check .git/config to see these parameters or open repository configuration from egit preference in Eclipse), this is similar to Team > Push to upstream in EGit. Usually the refspec used in this way is implicitly configured when creating a local branch based on a remote tracking branch. It's also possible to add this configuration later but since this is more
tedious manual configuration the other way is more handy.
If you clone a remote repository the repository you cloned from is stored as remote "origin" in your clone. This way you can skip configuring the remote manually. This is only needed if the repository is born when you create it from scratch.
The "Branching" section of the Egit User Guide can help:
There is no obligation to create a local branch which would be named like a remote tracking branch (see "Having a hard time understanding git-fetch" to have a good understanding of "remote tracing branches).
You can create as many local branches (i.e. branches that you won't necessary push anywhere) as you want/need.
But if you don"t see any remote branch, maybe you didn't fetch that GitHub repo in the first place: see Fetching.