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.
Related
I try to ignore a committed ".project" file on Eclipse EGit, without deleting it from my Eclipse project nor the repo.
I have this need :
the ".project" file of my Eclipse project must be committed at least
at the begining of the project, so that my co-workers can pull it
when they will "build" their Eclipse workplace
this file could be modified by any of us, but should not be pushed on GIT repo
this file must stay on GIT repo all the time, because a co-worker could have to get back the project at any time
we are working on Windows, so using command-line is a bit off-subject : I seek for help on Eclipse EGit
We are migrating from SVN to GIT : on SVN, we did not had this kind of problem, because we could not commit some files. On GIT, it seems that we have to commit everything we modify so that we do not have conflicts.
Can anybody help me ?
Thank you !
Right-click the file and choose Team > Advanced > Assume Unchanged.
See Eclipse Help - EGit Documentation - EGit User Guide - Reference:
Resources can be flagged "assume unchanged". This means that Git stops
checking the working tree files for possible modifications, so you
need to manually unset the bit to tell Git when you change the working
tree file. This setting can be switched on with the menu action
Team > Assume unchanged and switched back with the menu action Team > No Assume unchanged.
It should be noted that each co-worker must do this once. A server-side Git hook could reject commits changing .project if a co-worker had forgotten to do so.
I am looking for a way to work with different GIT branches and have the Eclipse workspace in sync. with the directory structure of the GIT branches. In this case the branches will differ as projects have moved around from subdirectoris. To illustrate:
master
plugins
plugin1
plugin2
feature1
topic_organize
plugins
plugin1
plugin2
features
feature1
I think the current Egit solution is not workable. What it does it close projects which are not in the new branch. (When I switch branches in the cmd line, is even more horrific, Egit actually recreates the missing projects! in this case, when I switch to branch "topic_organize", the project feature1 in plugins will be recreated by EGit, my repo is automatically not clean which I sincerely despise, when switching to a branch).
What it doesn't do (and should do) is to start with a clean workspace, and import all the projects and organize them in working sets and on top load the appropriate target platform.
The consequence of not doing what is should is, that I have to 1) manually import missing projects,
2) remove projects created by EGit which are in my repo, but not imported in the workspace. 3) Create working sets if these differ between branches. (In my case the working sets, are equal to the sub-dirs in the repository). 4) Clean my GIT repo.
As a best-practise towards a full solution is to create a team project set. The working steps would be.
Import your projects from GIT and add them to working sets corresponding to the directories in the GIT repo.
Export a Team Project set to a special project. (Make sure the location of this project never moves in GIT).
Commit this "team" project, so your GIT branch is clean.
Clean your workspace. (I mean start with a clean workspace by removing all working sets and projects).
Switch branch on the command line (You won't be able to switch with a clean workspace).
Select file import, import Team Project Set (.psf) file. (Assuming you did step 1,2,3 for the other branch as well).
tada your workspace is back with working sets and all projects open.
Change your target platform if needed.
NOW MY QUESTION :P
Do I miss something? Is this there a way to clean the workspace in one go? Now I have to remove the working sets first, then the projects by selecting them one by one! (Perhaps I should switch the workspace as well?).
Considering the way Eclipse work, it has only one version of a project available in an Eclipse workspace at any time (because the id of a project is its... name)
When one needs to "switch branch", I always prefer having:!
multiple clones of the repo (one per branch, I rarely need more than 2)
multiple Eclipse workspaces
Switching branch means switching workspace and updating the branch you are in, in that workspace.
As the OP user2736833 comments below (using git remote):
git clone repo br_dir
cd br_dir
git checkout br
cd repo
git remote add -t br_dir br_repo ../br_dir
Then:
git fetch br_repo
git checkout br
git merge br_repo/br
I already have a CVS and that cvs is used to share the source among other developers. But I need to keep a track of my source code changes separately. Moving the project from cvs to git is not practicable here.. and you may think that why 2 versioning controls. Any way I need to have a separate repository. I have tried git with eclipse. It is ok. I want to know how I can use both my personal git repository and cvs together in eclipse. (For example, when I commit my changes in eclipse, Team -> commit .. How can I separately commit to both cvs and git..and whenever I need to see the history in eclipse, separately git and cvs.. .Also when CVS server is not supporting, I can work with my local git repo as well. ) I need to handle all in eclipse IDE. Any one give any tutorial or links for my solution, it is highly appreciated.
You can have a git repo directly within your sources, but Eclipse would still be set on using CVS (and cannot show you both git and cvs commands at the same time).
That means you go on committing with CVS and Eclipse, but would need to commit (locally) in Git with an external tool (either a simple command-line session, or any GUI you want, like GitHub for Windows or SourceTree)
It actually is possible, if you create a dummy Eclipse project and designate the git repository at the workspace root (.git directory at same level as all projects in the workspace). This way when you make commits from this project, all projects in the workspace are its members and you can keep the members themselves connected to cvs.
You can create such repository by first creating the dummy project, and (Team->Share) sharing it via git using the Configure Git Repository dialog. Select “Use or create repository in parent folder” and explicitly remove the project folder from the "Create Repository" line after checking (checkbox) the project from the list of available projects.
After pressing "Create Repository" the project directory suffix will reappear, but remove it again before pressing Finish. In my version of Eclipse pressing Finish will hang, and I must terminate Eclipse to restart it.
After restarting the dummy project can be used to Commit files in all the other projects while the other projects remain connected to cvs.
Screenshot of “Use or create repository in parent folder” view when pathname has been entered by pressing "Create Repository" and then (corrected again before pressing) Finish.
Let's say I have several projects in c:\dev\ and want to keep them there (this is my eclipse workspace)
What is the least inconvenient way to setup egit?
Turns out there is a bug in egit where you cannot create a git repo on an existing folder
You need to use msysgit to create the git repo on the command line, using git init
Then you can use egit as per the user guide
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.