Home » Eclipse Projects » EGit / JGit » local eclipse php project git repository clone to another local directory(question regarding best way to have two local development repositories for the same project)
local eclipse php project git repository clone to another local directory [message #1863286] |
Tue, 23 January 2024 10:01 |
Eclipse User |
|
|
|
This may sound a little strange, but as you will see, there is a good reason for it.
Background:
I read in an article that it is best to start a PHP project in Eclipse before Team > Share it to Git ... apparently this is because it works best this way to allow Eclipse to recognise PHP formatting, and other PHP project settings ... and so a lot of tutorials and articles aren't much use to me, because they are all based on beginning with a remote repository on GitHub or elsewhere, but this isn't what I am trying to do.
I have a live server hosting the site, I have already successfully setup Eclipse in another workspace to have that site as a remote, and the GitBash terminal in Eclipse while in that workspace with that project open in the project explorer, returns the following (sanitised):
$ git config --list
remote.origin.url=username@domain:/home/username/public_html/projectrepo
remote.origin.fetch=+refs/heads/*:refs/remotes/origin/*
branch.master.remote=origin
branch.master.merge=refs/heads/master
$ git remote -v
origin username@domain:/home/username/public_html/projectrepo (fetch)
origin username@domain:/home/username/public_html/projectrepo (push)
NOTE: Unfortunately I forgot to write down how I got this far, because it was a little tricky in terms of creating a new PHP project from a Git clone of the live server, and I lost the URL where I found the instructions on how to do it ... but at least I got it working in the end
Next tasks:
So now that this repo is imported and working as an Eclipse PHP project, imported or cloned from the live site, with the live site set as origin, I just have to test the push pull fetch functions ... and hopefully all will be well ... BUT ... what I realised after creating that Workspace, was that I wanted to install WAMPServer, so that I could test and see results on a localhost before doing any pushing and publishing on the live site, but the directory where I created that workspace for Eclipse, wasn't going to play well and easily with WAMP, which of course likes to be set up at the root of a drive -- eg:
... so, I thought one of the best options, which would allow me to work very well locally, and without necessarily always dealing with WAMPServer, was to simply create a new workspace in the directory:
... and then I can import my project into that location (where WAMPServer is expecting to find it) from the other workspace, and set these two local repositories as remotes for each other, so I can push pull fetch etc between them as needs be ...
... but when I switch to that Eclipse-WAMP workspace (c:\wamp64\www), and then in Eclipse: Import Projects from File System or Archive > Import Source > Directory, and browse for the repo folder in the original workspace, while it does appear to import the project, and I can see the project in the project explorer in the new workspace, this has not created a new repo at that location, the files have not been copied, and if I right click on that project in the project explorer, and ask to see where the project exists via the Windows File Explorer, it opens the project repo directory in the original workspace ... but this of course won't help me to get WAMPServer playing with it nicely.
Here is what I want to do:
- How do I get this project not just imported but copied/cloned to the second workspace, BOTH as a PHP project AND as a Git repository
- How do I use branches to create a test in the original repo, which can then be pushed to and tested locally in that Eclipse-WAMP workspace cloned repo, then if working, pushed to the live server from the original local repo, so that if any difference between WAMPServer and the live server causes an unexpected problem, I could quickly revert the live server back to the previous commit or a safe branch or something like that
- Is there an alternative way of doing this, where instead of cloning the repo locally to that Eclipse-WAMP workspace (c:\wamp64\www\), I instead create an alias or something in myPHPadmin or something like that in WAMPServer, which points to or has a link from that directory over to the original repository in the original Eclipse workspace where the project exists
- I am happy with either solution above, whether having a local duplicate clone, or whether I can get WAMPServer to look from \wamp64\www\ over to the other workspace \users\username\workspaces\eclipse-php\ using something built in to WAMPServer ... does anyone know how to do this?
- Can anyone also clarify / confirm / correct:
- where a project exists in a git repo, and you want to make a local clone, but you also want it to be recognised by Eclipse as a project of a particular type (eg: Java, PHP, or whatever)
- the best approach is to begin with importing the project type you want, NOT begin with importing a Git project or cloning a Git project
- and then AFTERWARDS you use Team > Share to Git, to have Eclipse register it (or whatever it is doing) with Git, so that it is now an Eclipse project both of the type you wanted AND of type Git, with Eclipse support/functionality for both types
- is this correct, or have I misunderstood something, or is there a better and more accurate/correct description of the workflow and what is going on?
- ALSO: having used GitBash command:
git config --global pull.rebase true
... I found that in the Eclipse: Preferences > Version Control > Git > Configuration ... the User Settings tab says that I do indeed have pull rebase = true, but in the System Settings tab, it says pull rebase false ... so "--global" isn't all that global after all? What is going on there?
Thanks in advance for anyone who can help clarify and clear up the confusion here.
|
|
|
Goto Forum:
Current Time: Tue May 13 06:07:46 EDT 2025
Powered by FUDForum. Page generated in 0.03450 seconds
|