I created my own project in Eclipse (Kepler version for Parallel Apps) using PyDev, then pushed it to GitHub.
Now, when I try to switch branch using "switch to" in Eclipse, there is only one option: "New branch". It doesn't allow me to switch to any existing local branch or to look for remote branches. But on the other hand I can switch to another branch from command line or even from Eclipse "Repository view".
I thought it might be problem of configuration of my branches, so I created new branch on Github and downloaded project again. It was fetched, but unable to use "switch to" option.
But when I download other projects from GitHub I can switch to other branches.
Any ideas where is a problem?
Related
I am new to Eclipse as well as Git world. Following question may sound like really dumb thing to ask, but I have spent hours finding how to do it and found no way.
We have a Git remote repository that I have cloned using Eclipse's Git perspective. My team makes some changes to code and pushes them to remote repository. I am stuck with "getting latest" code in my local workspace.
Here is what I tried:
Open Java EE perspective. Right click on my project -> Team -> Synchronize Workspace. This opens "Team Synchronizing" perspective. It shows me that there are some "incoming" files, but there is no option to "get" them. Only options I see are Merge, Overwrite, Commit. Well, none of them make sense to me.
In TFS world, I just select "get latest" and new versions replace old versions in local workspace. What am I missing?
The Synchronize View will only allow you to inspect the differences between the resources in the local workspace and a local or remote tracking branch.
It won't get the last commits.
For that, you need to pull new changes from the upstream branch
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.
This also works if resources are selected from more than one repository.
See for instance "EGit Auto-Merge and Conflict Resolution "
To understand more about that workflow, look at GIT Illustrated Cheatsheet -- Working with remote repositories
Currently using Eclipse Mars.1 and installed EGit from Eclipse MarketPlace.
Does Eclipse EGit has a similar feature of SourceTree wherein you could pick N or all commits inside a branch and compare it (git diff) to which branch is was checked-out from?
I was trying to follow low-level git branching standards relying only on Eclipse EGit tools (without terminal, SourceTree, Pull Request functionality, et.al.). But I'm only limited to seeing commit-diffs and not a branch-commit-diff view.
I think you can compare anything to anything in egit.
e.g.:
You can click on any two commits in the History view and, from context menu, choose Compare With Each Other
You can select two branches in the Git Repositories view and, from context menu, choose Synchonize with each other
You can right click on any branch in the Git Repositories view and choose Synchonize with workspace
And the list goes on ad infinitum (practically).
Good morning.
I just create a GitLab private repo to work in a project with some people. When I add GitLab repo to Eclipse, it says there aren't projects (and it's true). I would know how to create a project and sync with online repo so other members can see my project and codes.
I tried to start a project in git\repoName\ folder, then right-click and choose Team->Commit, but changes wouldn't save (in gitLab repo's website, it says "Repo is empty").
I tried to follow some online guides, but without success.
Sorry for bad english!
Eclipse 4.2 and newer, comes default with (E)Git installed. There is a good Eclipse git tutorial from Vogella.
Create a GitLab git repository
Log into GitLab
Create a project / git repository
Copy the https url from the project, used for cloning
Adding an GitLab git repository in Eclipse
Open the Git perspective in Eclipse
Use Clone existing Git repo, as shown in Using git repository view
Now all the git functionality from Eclipse can be used.
I assume you have a cloned repository available in Eclipse (eGit) that is empty. If not, follow the steps in the answer from Verhagen.
By now, you have a cloned repository that is marked with "[NO HEAD]", indicating that no commit has been made.
Start creating a new project by using your project type of choice; I'll use Java project for simplicity: File menu > New > Java project
in the New Java Project wizard un-tick the "Use default Workspace location" checkbox; instead, choose the directory where you cloned your empty GitLab project, and append the name of the project (this is to make Eclipse create a directory inside the repository, just in case you later want to create more projects in the same repo).
Fill in the wizard as you usually do. When you are done with the different steps, you'll have a new project, that is also marked with "[NO HEAD]"
Create some source files you want to share (e.g. HelloWorld.java)
Synchronize workspace (right click on the new project > Team > Synchronize workspace) you will see that now there are files to commit. Pay attention to those files, since some of them ( .gitignore, and maybe .classpath, .project,.settings directory... depending on how you share your projects) you'll want to add to the .gitignore.
right click on the files you want to commit, fill in the commit message and click "Commit and Push". Click Next
Since it is a new repository, you'll have to configure the Push action. I selected HEAD as source and HEAD as destination. You might want to do the same, at least for this first commit+push; later on, you might choose to add some specs for branches, etc.
The Push Confirmation will show you that the new branch master:master will be created.
Both project and repository lost the "[NO HEAD]" marking
You can check gitlab site to confirm your files are there.
This is the first time I do this.
I imported a git project in eclipse.
Then I used the shell to create another branch and checkout to the new branch.
Is refreshing the imported project in Eclipse enough to tell Eclipse that we are working on the new created branch?
thanks
Right-click your project and select Team → Branch to create new branches or to switch between existing branches. You can also switch branches in the History view.
Actually, I don't think you even need to refresh the project. That is, assuming you have 'eGit' installed and your projects are already configure as git projects (they should be, because in most cases, egit does that automatically).
Whenever you run git commands on the shell (outside eclipse) egit will automatically refresh projects for you and update their status when you switch back to Eclipse.
If you are not using egit then yes, you have to refresh the projects manually, but that is all you'd have to do since running the 'git checkout my-branch' command in the shell already changed the files on disk to be those from 'my-branch'.
Actually when you are working with eclipse, eGit is a very cool tool integrated inside eclipse, which lets you do all git stuff, like
git checkout to a new branch
git create new branch
git stash
even view your unstaged changes(select files and avoid complexities caused by git add .)
and finally commit.
Read here to know more. Eclipse Egit user guide
So you get to do all version repository stuff at one place as you code.
So to answer your question, yes as you checkout a new branch even in a shell/command prompt your changes will be reflected in eclipse.
I am trying to adopt the following workflow:
git svn clone a svn repository through command line (egit doesn't support git-svn)
Open the project in eclipse with egit since I rather use egit to branch, merge, commit etc...
When i'm ready commit the changes back, I use use git svn dcommit to commit back to svn
I am having trouble with step number 2, don't understand how to import a git project, eclipse tells me i can't import it to use the same directory it's currently in because another project with the same name is already there. this is confusing.
Anyone knows how to do this ?
Also would like to hear other workflow examples that uses egit and git svn. I am aware that it is better to do it all through command line, however, I am trying to ease the move to git for fellow developers in my team, who are not used to command line interface etc...
I've worked briefly with the egit plugin (I actually recently stopped using it and just use msysgit as my Git guiclient and run it separately from Eclipse). I find Eclipse very busy as is and adding this plugin slows it down (for me at least).
What I did when setting up an already cloned project in Eclipse:
In Eclipse. File -> Import -> Existing Project into Workspace
Select root directory of project. Do NOT check copy projects into workspace. Click finish.
After project has been imported. Right click on project, go to Team -> Share Project
Select Git as a repo type, click next
Check use or create repo in parent folder of project. Since you already cloned the project it will be tracked with git. When you check this option it will show the project, the path, and the repo (.git).
Click finish and you will be all set.
I think you'd better use SubGit instead of git-svn.
SubGit works on a server side. It synchronizes all the modification between Subversion and Git repositories automatically on every incoming modification from either side.
From the client perspective SubGit enabled repository is a usual Git repository, so you may pull from and push to it. Please refer to SubGit documentation or SubGit vs. git-svn comparison for more details.