I set up an SVN repository for my Android project the wrong way and I would appreciated some help correcting it.
I created a standard SVN repository as follows (I did not create a root "svn" folder because I only plan to store one project in this repository):
http://myserver/MyProject
/trunk
/branches
/tags
When I checked in my project it went into the root folder instead of the /trunk folder. So I had the folders:
http://myserver/MyProject
/trunk
/branches
/tags
/MyProject
/src
/res
/...etc
I've been working this way for a while, using Eclipse and (I think) the Subversive SVN connectors. I know NOTHING about the svn command line. Now I need to move my project to the trunk folder as I should have done from the beginning. I copied the MyProject folder to the trunk folder by copy/pasting in the SVN Repositories view in Eclipse and renamed the old folder, so now I have:
http://myserver/MyProject
/trunk
/MyProject
/src
/res
/...etc
/branches
/tags
/MyProject.old
/src
/res
/...etc
How do I get my project to start using /trunk/MyProject? Ever since I renamed /MyProject.old to /MyProject Eclipse cannot find the remote files when I sync. I tried changing the repository location from
http://myserver/MyProject
to
http://myserver/MyProject/trunk
but Eclipse warns that "The repository root URL refers to one of the resources configured as a structure node. Do you wish to normalize the URL by cutting it's last segment off?" If I say Yes I'm back in the same boat and if I say No I get nasty errors when I try to sync.
How do I get my code syncing to the new location? What am I doing wrong? I'd preferably like to keep my revision history and not start over again!
Thanks in advance,
Barry
The easiest thing to do if you're not familiar with the SVN command line is just to use TortoiseSVN then open up the Repo Browser: Windows Explorer -> File -> TortoiseSVN -> Repo Browser. Now drag and drop your folders or create new ones just like you would in Windows Explorer.
After you've done this, you'll also need to perform a "switch" on your working directory so it points to the new repository path: right-click -> TortoiseSVN -> switch.
Have a look at this thread:
How do you move a file in SVN?
I think the best option for you is to put everything back as it was before you copied the folder over. With svn, you have to be careful when you move/copy stuff around, because each folder contains a .svn folder. Inside that folder there are references to the actual repository, so when you modify the underlying file system, you bring the working copy in a very unstable and out of synch state.
If you don't have many local changes, you should probably do a fresh checkout. When you are done with that, you can follow the suggestion in the above thread to use svn commands to move folders/files around.
Related
I used computer A via the Terminal to create a) create a git repository, b) add an index.html file to the repo, c) add a remote origin, d) push to the remote origin. All OK.
Then, i used computer B to clone that repository via Terminal. Then, I opened Eclipse (equipped with Egit), and created a new project in the folder that was created by the cloning process. Then I used Eclipse to push any changes to the remote origin.
Returning to computer A, I used Eclipse to create a project in the original repo folder, and then I attempted to pull from the remote origin, in order to get the changes that were pushed when using computer B.
Eclipse will not do it. It complains the I have items such as .settings, .project and similar and since they are not under version control it won't overwrite them by fetching files from the server. I had to manually delete those files (via Terminal) and then Eclipse worked as expected.
Please provide information on how to avoid this.
Should I create the local repo from within Eclipse and then push it to the remote origin, so that items such as (.settings) are under version control and (if so) how would that cause trouble to people cloning the repo and use different versions of Eclipse?
Should I gitignore those items?
Should I ask Eclipse to save its own affiliated files to another folder (not that i am aware how to do that, i only know that NetBeans does it)?
Looks like you didn't gitignored eclipse files.
Probably, when you commit/push via egit, you also commit and push those files you already had unversioned in your machine A, so git complains, because you are asking to override existing unversioned files.
I strongly recommend you to gitignore those eclipse files. You can see examples of .gitignore files in the github gitignore repo.
Hope it helps.
It complains because if you pull the changes from your remote it will overwrite your local files. That is the problem. The other answerer has right. You should better add all the eclipse project files and and target .settings and classpath to gitignore. You can use a global gitignore for your computers as well, before creating projects. You could use maven for example, then you can import your projects only from the pom.xml-s given in the git repository.
I use them the same. Egit and other guis are a bit too complex to work with. Git repositories can get easy in an inconsistent state where you should use the oldfashioned terminal to solve things. Like, rebasing, merging on conflicts. Gits learning curve is solid.
Now you can solve your problem if on the first computer save a backup of your original and clones your project later, after fixed it on the second. On the second git remove all this files, but use the --cached option to avoid deleting them. Before you do it so, check the help of git remove! after you have done this, put them into the .gitignore as filenames with wildcards. You can also use a global gitignore file in your user folder. Creating a .gitconfig file where you can specifiy the global ignore with the following :
[core]
excludesfile = ~/.gitignore_global
Than just create the .gitignore_global like this :
/nbproject
/bin
/build.xml
.idea
chess.iml
target/
bin
( This file is for idea and netbeans. you can add eclipse project files here )
You can have .gitignore files per project too. You can commit them to the repository, so on the next machine you do not have to do this again. The nicest way I think is having a dotfiles git repository, which is a git repo of your home directory and the dotfiles in it. I also use it for different windows and linux distros.
That's all. You should keep all of your configuration in a safe place. And source code management can do it. But do not commit private stuff to public a place! ;)
Oh I wanted to mention that, you can also have a .gitignore entry in your .gitignore file. That can be very useful when you do not want to touch a repository but need to add a gitignore to hide some stuff especially from the given repo.
I am new to Egit and created a new repository for a GWT project I'm working on. Unfortunately, I let it create the repository under my Dropbox folder, and now I'm regretting it because I'm syncing megabytes of temp files (e.g. *.class) over the internet. The "create repository" wizard also moved the project's files from the Eclipse workspace to a working directory under Dropbox (along with the .git folder).
What is an easy way for me to move this Egit repository and working directory to somewhere else, other than the Dropbox folder?
(btw, since I'm using Egit, the solution needs to work such that Eclipse is happy and I can keep building/using my project).
I managed to do it myself, here's how:
In Eclipse, right-click MyApp project, Refactor->Move. Move the Eclipse project to a new spot on disk. Note that I kept the .../GitRepositories/MyApp/MyApp dir structure, it's just that I moved the location of GitRepositories to a new place. Also note that this left the old dir with nothing but the .git folder inside it (i.e. Eclipse moved the working files/dirs but not the repo).
Close Eclipse
Move the .git directory from the old directory to the new. Be sure to keep it in the right relative place! I accidentally moved .git from .../GitRepositories/MyApp to .../GitRepositories/MyApp/MyApp. This screwed things up and I had to back track...
Start Eclipse
It might already work at this point, but because I moved .git to the wrong place when I first did it, I had to do the following steps:
Right-click MyApp project, Team->Disconnect
Right-click MyApp project, Team->Share Project...
The wizard automatically finds the Git report relative to the project dir: ../.git
Happy hacking...
When working with a local repository, you can just do the following:
Close Eclipse
Move the git repository on disk
Reopen Eclipse
Select File->Import... -> Git -> Projects from Git
Select local repository and add the new repository location
Select your project(s) to be added
(Optional) Remove the old project references from your workspace.
It may seem like a lot of steps, but it's actually very simple and less invasive than moving the repo and working copy separately.
Im very new to git ingeneral, egit and github.
The problem:
Lets say I have a project for eclipse in c:/username/workspace name "Test". So I versioned it and pushed it up to github.
Now I can see all my Files in github under the directory "Test" in github. In example /src. The "Test" directory is not versioned. only the name of the repository is "Test".
My next step was to delete my local files and fetch my project again(For testing). After that I had to import my project again (but I had to use the new project wizard) over the egit view. Unluckily also the wrong scala version was detected. (Was a play framework project). So I had a big exclamation mark on the project view.
My questions:
What is the best practice to oush a project to github so everyone can participate? Everything under the project folder? Obviously some information got lost through the process.
How can I prevent to generate a new project every time someone clones the repository?
What about best practices for using git inside the workspace. Eclipse warned not to put the project inside the workspace.
Im coming from a subversion background :/. Maybe a general missunderstanding.
Thanks in advance
Switching from SVN to Git in an Eclipse environment can take some getting use to. (I'm still getting accustomed to it myself.) Keep in mind the difference between the role of the .git folder and the .svn folders for Git and SVN respectively. There is a .svn folder at every folder level in the working copy. There is no .svn folder in the traditional Eclipse workspace root. The "source controlled things" are subdirectories of the workspace, not the workspace itself. This is generally good because the workspace contains desktop specific settings that one generally doesn't want shared (much of it in the .metadata directory).
With Git, there is only one .git folder that contains everything. The first impulse is to do a
git init
at the workspace level. This would make the subfolders (the Eclipse projects) eligible for source control. But wait, so is .metadata. Of course you can ignore it. But you may have to ignore lots of other folders (projects) that you do not want source controlled. Of course, the .gitignore should be included. But others will have different files to ignore.
It turns out that its easier to use Git with Eclipse if you place the .git folder and its sibling source controlled folders (Eclipse projects) someplace else besides the workspace root. Your view in Eclipse doesn't change. You still see all your projects, both the Git-controlled and the SVN controlled and ones not shared at all. But underneath in the filesystem, the Git-controlled folders will be somewhere else. This is what EGit prefers.
On my desktop, I have a workspaces directory for most of my Eclipse workspaces. Now that I use EGit, I also have an egit directory where I keep the local EGit repositories. The Eclipse workspaces that share using EGit reference a subdirectory of egit. It's from these local Git repositories that one pushes and pulls from GitHub.
Sorry for the length. I got a bit carried away.
It's funny, I've been working with SVN (Tortoise on Windows) for a relatively long time, but I've never used other actions than checkout, commit and merge since the projects I worked on already existed.
Now I want to put an Eclipse project under version control by my own and realize that I am too stupid to do that. There is already a new SVN server with emtpy branches/tags/trunk folders, it was created by another person.
1.)
My intention is to add three subfolders to the trunk folder - these three folders are just for a better structure, they should not have anything to to with version control or my eclipse project (apart from the fact that I want to put my Eclipse project in one of those three folders in the second step).
But how can I do that? I created those three folders on my hard drive via Windows Explorer and tried to put them in the SVN's trunk folder by using the import function of Tortoise. This failed with the following log message:
Command: Import C:\New Folder to https://<SVN-Adress>/trunk
Adding C:\New Folder\folderA
Adding C:\New Folder\folderB
Adding C:\New Folder\folderC
Commit blocked by pre-commit hook
svn: URL file '<SVN-Adress>/trunk/folderA' non-existent in that revision
svn: URL file '<SVN-Adress>/trunk/folderB' non-existent in that revision
svn: URL file '<SVN-Adress>/trunk/folderC' non-existent in that revision
2.)
In the second step, I want to add my eclipse project to folderA and another eclipse project to folderB. Since there is already content in the eclise project folders, the "Create Repository here" command of Tortoise SVN doesn't seem the way to go. Apart from the question how to do that properly, is there something to be aware of? E.g. are the two eclipse projects independet and isolated later on or does a commit of the one project also increase the version of the other project?
Thank you
Checkout https://<SVN-Adress>/trunk to your root folder (c:\New Folder), then SVN-add all the files and folders you want to be in source control, and commit.
Issue
After importing an Eclipse project from a cloned git repository, I make some changes and commit - and wtf? I get a ".git" folder added to the project, the whole shebang with the heads and refs and worst of all the whole object database gets added to the project, all files/folders having that little question-mark icon signaling that the files have not been added / are not yet tracked by git. This .git folder exists in the actual Working Directory (how does that even make sense?). You can imagine what an annoyance this causes when trying to use the "Synchronize" tool/view (which is supposed to make life easier for committing, you can see all the changes and changed files and diffs).
Question (tl;dr)
How to correctly import an Eclipse project from a cloned git repository? I don't want a .git folder showing up in "Team > Synchronize" when I commit, let the .git folder reside somewhere else outside of my project.
Additional Info
I'm on Windows 7 using Eclipse Indigo and Egit.
I am using Egit to clone a git repo from http://git.apache.org/ (the ofbiz project, to be exact) and in the wizard I choose the option to import an existing project from this newly cloned repo.
Yes I am aware of how little I may expect from Egit. In fact, if there are any alternative ways (external git tool? command line git for windows? other?) to use a git-tracked project in Eclipse which keeps the actual .git stuff out of the project, i'd gladly abandon Egit.
When you clone a git repository, the default behavior is to create a .git folder inside the root of the local clone. You can change the default behavior by setting the GIT_DIR variable:
Git docs says:
"GIT_DIR
If the GIT_DIR environment variable is set then it specifies a path to use instead of the default .git for the base of the repository."
Depending on which terminal you use, you could set it using setenv or export.
For example in a bash terminal:
export GIT_DIR='[path_to_git_directory]'
After setting the variable, you should be able to clone and the .git directory should show up at the specified directory.
I totally agree - I can't imagine it would ever be anyones intent to commit the .git folder!
And git/EGit knows that this is the repository folder of the project, so it should be easy to implement the appropriate exception - so that this folder does not become part of the synchronization.
I know the following does not solve your problem, but in cases where you control the way files are layed out in the repository, you could choose to have the Eclipse project folder not be the root folder of the repository, but rather a sub-folder.
This also allows you to have stuff in the repository that should not show up in Eclipse, or even have multiple Eclipse projects grouped in one repository (if you should wish to do so).