How do I get a new branch to show up in Eclipse Git Remote Tracking? - eclipse

I have an existing Eclipse git project, with a master and development branch present in both local, and remote tracking. I have just added a new branch in my git repository, but I can't figure out how to get it to show up in Eclipse.
I have tried to read up on the subject, but it seems like it is just expected to automatically show up. I have found a lot of similar questions, but they all seem to deal with the issues of a completely empty remote tracking folder, instead of my problem of only a single new branch missing. I already have Master and Develop present.
Here is what does not work:
Clicking refresh in the Git repositories window.
Any kind of synchronize, pull or other update I can find
Here is what would work:
Right clicking the remote tracking folder, and selecting "Paste repository path or URI". If I do that, and select the exact same path as is already there, I can see my new branch. This action does require that I completely clone the whole repository to an empty folder again, and that can't be how this is intended to work.
I believe it might work to use some kind of command line tool, but I really want an Eclipse solution to this, as I feel sure it exists, and I am just missing something.

In the Git Repositories view:
Right-click the repository and choose Fetch from Upstream
If the new branch will not shown up below Branches/Remote Tracking, you have to configure fetch:
Right-click the fetch node below Remotes/origin and choose Configure Fetch...
In the Configure Fetch make sure there is only the single Ref mapping (assuming the remote is named origin) +refs/heads/*:refs/remotes/origin/*:

In case you do not see Fetch from Upstream after right-click the repository, you may look for Fetch from origin.

For me the solution was almost what Joshua suggested, however it did not work as described. For me the solution was to configure the [remote "origin"] property as follows:
[remote "origin"]
url = your_git_url.git
fetch = refs/heads/*:refs/remotes/origin/*
Alternatively, you can do it from the Eclipse UI too:
Fetch from origin... then hit Configure... and in the configuration window hit Advanced... and there you have the option to Add predefined specification where you can selec Add All Branches Spec. This will result in the same configuration as above:
Maybe you have to remove your original entry which will be pointed out as a duplicate by Eclipse.

You need to modify the "config" file in your local git repository folder. For example, you cloned a remote branch Project into c:\git\MyProject local folder. In this folder there is a hidden folder ".git" that has a "config" file. There is a section in this file resembling the below
[remote "origin"]
url http://xxxxxxxxxxxxxxxx
fetch = +refs/heads/Project:refs/remotes/origin/Project
You need to modify this section as below
[remote "origin"]
url http://xxxxxxxxxxxxxxxx
fetch = +refs/heads/:refs/remotes/origin/
Then go back to Eclipse IDE, right click on the repository and do a "fetch from origin". Now all the branches will show up.

What I did:
1: disconnected.
2. refresh and pull. Then, it shows the new branch
3. create local and pull.

Related

New to git--just need to sync one file

I managed to finally get EGit in Eclipse to work (still don't know how) and I've committed/pushed my current project up to GitHub. So far, so good. Looking at it on GitHub's site, I see it wants me to make a README.md file to provide a nice description. Fine, I think, I'll just use the tool it's providing me with to get it started, then have it sync back down to my local computer where I can further modify it and keep it synced.
So I created a quick README.md file on GitHub's site. But now, when I perform a "Pull" action in Eclipse, I am told that there's nothing new to pull, or something like that. Why is it not getting the new file that was created on GitHub's site, and how can I get it so that I can make changes to it whenever I want?
If you have git installed you can use a terminal and type in the root of your repository:
git pull origin master
or you could try checking out only that file:
git checkout README.md

EGIT rejected non-fast forward

I'm on Eclipse 4.2.1 (Java) and trying to use EGIT. My account is all set up on Github. No one else is working on it so there are no changes. I have a very simply project containing a single file with one print statement.
I created my local repo and added the project. (project explorer shows: [gitrepo1 master])
In project explorer:
right click on project -> team -> remote -> push
But I get: master: HEAD [rejected - non-fast-forward]
I've configured the push:
Branch -> master
URI -> ssh.git#github....
Ref mappings -> HEAD:/refs/heads/master
What am I doing wrong?
We had this problem, because we amended a commit after pushing it.
The solution was to merge origin/master (in Branches > Remote tracking), then push.
egit works by using jgit which is an implementation of git that is using java. the best thing to do is verify that the repo works with the normal git client. From your question it is not possible to know exactly how things ore configured.
When you get the error message that you could not do a push because it is not a fast forward, it means you need to do a pull first then, do the push, so try that.
Same cause as Bernát: I amended a commit after pushing it. Merge failed because of conflicts.
My way out: Context menu 'Team/Reset' selection 'Remote Tracking'/'origin master' option 'Mixed'. After that all my changes since last push were marked and I could commit and push.

EGit, selecting correct parameters for URI, Host, and Repository Path.

I am very new to GIT and am trying to check out some example projects from the eclipse.org git repositories. I just installed the EGit plugin and have reached a roadblock when trying to enter the correct parameters at the "Import Projects from Git" menu.
The location of the examples I wish to check out are located here.
http://git.eclipse.org/c/cdt/org.eclipse.cdt.git/tree/dsf
However I am unsure how to create the correct URI, Host, and Repository Path from this url.
I would like to be able to explore the different repositories listed on that page (for example the org.eclipse.cdt.examples.dsf folder) and checkout those projects, however I just can't figure out what the correct git url for this would be.
I'm coming from SVN, so I am sure I got some terminology wrong. I have been following this tutorial for using git: http://wiki.eclipse.org/EGit/User_Guide#Cloning_Remote_Repositories
If you click on "Summary" in the page you mention (http://git.eclipse.org/c/cdt/org.eclipse.cdt.git/tree/dsf), you will get a page (http://git.eclipse.org/c/cdt/org.eclipse.cdt.git/) which displays, at the bottom (you need to scroll down), the clone addresses:
Clone
git://git.eclipse.org/gitroot/cdt/org.eclipse.cdt.git
ssh://git.eclipse.org/gitroot/cdt/org.eclipse.cdt.git
http://git.eclipse.org/gitroot/cdt/org.eclipse.cdt.git
You can use one of those addresses to clone from Egit: see "Cloning Remote Repositories" from the user manual.
This page contains documentation from the Eclipse project about cloning their git repositories. They show an explicit example for the org.eclipse.cdt.git repository. You can use either this:
git clone git://git.eclipse.org/gitroot/cdt/org.eclipse.cdt.git
Or this:
git clone http://git.eclipse.org/gitroot/cdt/org.eclipse.cdt.git
I usually use git:// URLs when they're available. They used to be faster, but this may not be true anymore. Either should work just fine.
In general, it looks like repositories are available from git://git.eclipse.org/gitroot/<PROJECT>/<REPO>, where it's up to you to correctly substitute <PROJECT> and <REPO>.

SVN authorization failure, trunk non-existent in head revision, getting a GIT repository working in Eclipse

To simplify things, I have one local SVN repository D:\folder\repo_name and I have svnserve running as a service with root set to the mentioned path. Subclipse and SmartSVN can connect to the repository, also displays the correct head revision number, but when I try to explore the trunk (the only branch) it gives the following error: URL 'svn://localhost/trunk' non-existent in that revision. This while I can check out the complete repository perfectly fine. But I don't need the all the branches, I need just the contents of the trunk.
When I try to commit I get the error Authentication failed. However my credentials were fine when checking out earlier.
When I try to get my stuff out of there and move to GIT (which I suppose would be best as everything is always kept local), the git svn clone process completes, I see all my revisions and files pass in GIT Bash, and then try to import it in Eclipse. I see that it tries to import the project into the repository directory itself (see http://wiki.eclipse.org/Image:Egit-0.9-import-projects-general-project.png). Needless to say I get the error in the shape of D:\folder\repo_name_git overlaps the location of another project: 'repo_name_git' What I don't get is why I can't seem to find a single way to let me specify where I want the project to import into.
Alternatively, when I add the project in the git repository as an existing project into Eclipse, and then - through the Team > Share menu - try to get under version control, I get the error Can not move project to target location D:\folder\repo_name_git, as this location overlaps with location D:\folder\repo_name_git, which contains a .project file
I'm at a loss and these errors are to generic to give me an idea of how to tackle them. Any heads up would be appreciated.
2 points:
I was getting "Authentication failed" on "correct" credentials - except the plugin I used was forcing the first letter of my username to uppercase - check the case of your username (upper or lower).
I've just had a problem moving onto a Subversion 1.7 repository, which is not supported by my Subversive plugin, and I was getting some strange errors.
You need to check the credentials
make sure svnserve is not started with -R {readonly option}
Check if the following lines are commented in
"\REPO_NAME\conf\svnserve.conf
anon-access = read
auth-access = write
password-db = passwd"

Eclipse/Egit, Push to Remote menu choice is grayed out

I created a repository on GitHub. I set up a local git repository using Eclipse and Egit.
With Team > Remote > Push. I managed to push the local repo to the one on GitHub.
Now I expected to be able to use the Team > Push to Upstream (as well as fetch from upstream) as a one-click push (and pull/fetch), but this menu choice is not available (grayed out). I have to use Team > Remote > Push to each time manually fill in the info (ctrl+space helps).
Following this, I created a remote configuration and pushed from the repositories view, and I can see the remote GitHub repository listed under Remotes but still the Team > Push to Upstream command is grayed out in the menu.
Could someone please give me a hint as to what I have may done wrong?
Here's what I did and this worked fine:
Right click your project, choose Team→Show in Repositories View. You will switch perspectives and be in the Git Repositories tab.
Right-click "Remotes" and choose "Create Remote". For "Remote name", enter "origin". Click OK.
Click Change. Enter your information as you did during your initial push. Click Save.
You should now be able to push by merely right-clicking on your project, then Team→Push to Upstream.
Because the remote was added under the project in question, each project can have its own upstream origin and they will not interfere (whereas the Window > Preferences solution is a global setting).
Based on your description of what you did, it appears you attempted this - but possibly did not use the name "origin" for the remote, which is absolutely necessary. I stumbled across this solution by pure chance.
I had this problem and thankfully found a way to re-enable the "Push to Upstream" option.
Go to Window > Preferences > Team > Git > Configuration.
Select the Repository Settings tab and then the repository that represents your project.
Click "New Entry..."
The key is remote.origin.url
The value is the url you copy from github. It's usually offered predominantly on whichever site you register with.
Perhaps there is a neater way of achieving the same thing. Once I reached this far I stopped looking because it works now.
You need to have the following type of configuration in that repository's .git/config file:
[branch "master"]
remote = origin
The remote setting can be any of your remotes or just a value of .
You can edit the repository's config by selecting the Properties menu item from the context menu for the repository in the Git Repositories view.
I came here searching for solution to solve similar problem with bitbucket - although none of the two highest votes answer didn't work for me, it proved that I had option "Put branch...", when I tried to do this, it says "Non fast-forward", but when I successfully made "pull", I was able to push to upstream.
Maybe it will help someone :)
This post might be a little old, but I had the same issue with one of my repos the following information from this link worked for me: Adding a remote to an existing git repo
The part i want to highlight from that article is the following:
[branch "master"]
remote = origin
merge = refs/heads/master
When I made the change in the .git/config and refreshed eclipse the "push to upstream" link worked for me. Keep in mind, I am assuming that you have a remote configured in your Git perspective for your remote repository.
In my case all git commit/push operations are inactive. I fixed the issue by placing the repository folder under git directory.