What Egit actions do I take to get copy of src file TESTGIT1 from MainServerRepository into LocalServerRepo to work on? - eclipse

As a new Egit user, aiming to set up version control to update the way a team manages source code without changing locations of our build and dev servers and to identify correct Egit commands to use for check in and check out code from both servers.
In a single Eclipse workspace, initially had one project without use of Egit just a basic automatic and adhoc file copy back up of changed development directory into folders with dates of backup. Promotion to the build server was done by manually copying source files and binaries, doing a diff between source on the MainServer and local server to manage any merges. Now need to implement a proper version control system, using Egit, so as a first time Egit user. I have set up two test Eclipse projects in my workspace: project A shared with MainServerRepository and project B shared with LocalServerRepo. The two git repositories will be in different directories: MainServerRepository on the network and LocalServerRepo on my area on the network where I backup my PC.
What Egit actions do I take to promote latest TESTGIT1.src from MainServerRepository into LocalServerRepo to work on in my local server? (Team > Fetch from upstream is grayed out). Then, once tested, how do I check in src for TESTGIT1 into the main build server project, source and objects are in MainServerRepository?
I've used Team > Commit successfully to check in, but am using cut and paste to move code between two projects (prior to commit) and feel there must be a better way to do this or to set up the projects differently within Eclipse.
Or should I be using Team > push or Team > merge?
Do I need local repository or should I just check out into workspace?
Any comments/ question/assistance would be welcome as haven't figured it out from reading the EGit/User_Guide.

Edit TESTGIT1.src in Eclipse project shared with LocalServerRepo(testGitRepo) until work on it is complete on local server. Then, apply same changes to TESTGIT1 in the main build server project, using right click copy +paste from right click, team > check in. Then in Git Staging view, click plus sign to add to index (staging area), then click commit button, merging in with any other changes made to TESTGIT1.src by other developers. Don't use push command to push entire contents of LocalServerRepo. Or is there a better answer?

Related

When I add a solution to source control in VS 2019 Azure Devops only the startup project gets added - how do I add the others?

I am working on a solution that has 14 projects (so far) in it. I added the solution to Azure Devops source control and can see that the solution and the startup project have the little locks in the solution explorer, also I can see the startup project files in the devops repo, but I can't see how to add the other projects. Obviously I messed up somewhere, since ideally the repo would contain a folder for the startup project rather than the files themselves, but I don't know how to "undo" the source control and reset my solution back to its original state.
Can someone tell me how to either fix the source control so that the master branch contains all of the projects in sub-folders (as per the visual studio folder structure) - i.e. how to move the startup project files in the devops repo to a sub-folder and how to add the other projects to their own sub-folders, or, failing that, how to undo the source control so that all of my solution files are back on my local hard disk?
Any advice will be appreciated.
You mentioned that you are using git. So when you DO NOT have local changes which are not pushed to your git server, that means everything is "synced".
Make a backup of your folder, just copy & paste everything!
You can just delete the .git folder. So you have no "link" to the git server anymore.
You can the link the "folder" again to your git server, with sth. like:
git remote add origin https://YOURNAME.visualstudio.com/YOURPROJECT.git
Other option is check your .gitignore file, maybe some of your projects are excluded.
When you are working with Visual Studio, can can also create a new empty solution and add the projects one by one. Also be sure that there is NO Filter in Project Explorer in Visual Studio.
You can also check your git changes, with git log or git status from any terminal or command line tool.

Is it possible to share a project without commiting?

I'd like to use "Share Project..." in Eclipse without actually commiting to SVN. Unfortunately, I am not able to find an option for doing this.
Instead, I want the relevant files only be added to SVN.
My goal is, that SVN should track all the files I move into the project using the package explorer.
Share Project needs to accomplish two things:
It sets up some internal linkage in Eclipse that connects your project with the SVN Team Provider so that SVN menu actions are exposed and so that activities you perform are routed to the SVN provider to "handle".
It has to establish your project as SVN "working copy" so that the SVN API that needs to be called on behalf of your actions can do what it needs to do.
So the key here is that if you already have a SVN working copy then Share Project will recognize this and be able to do option 1 without needing to do anything else. But otherwise, it has to establish a working copy which requires it to do svn checkout from your repository. If it has to create the working copy then it makes the assumption it needs to create the project in the repos and then check that out on top of your local project. So the one commit it will do is a svn mkdir for a folder in the repos.
If you do not want to do that, then do something to establish a working copy locally before you get started, such as checking out some existing location in your repository. As others have noted, you may want to be using branches and switch if you are refactoring something that already exists.
When you commit data to the SVN repository, you publish this new data or make changes to existing data (i.e. you make your changes available to others). Therefore, you need to commit your changes if you want others to see it in your SVN repository and collaborate.
As far as I recall, "Share Project" command in Eclipse is designed to import your non-versioned project to the SVN repository (i.e. make a first-time import) -- it converts your local data into a working copy and commits it.
I do not understand what exactly you mean by "share but not commit" (you may want to elaborate). However, you can always select which files to add and commit or import into the repository, but I guess that you will need to use standalone SVN client outside of Eclipse.

Eclipse - sharing project directory with multiple users

We are trying to set up Eclipse so that two users can share the same project directory on our server. Is this possible? Every time we try, it creates a new folder and project.
Thanks!
Chris
No, this isn't possible. Eclipse only supports a single user accessing a workspace (not just a project) at a time.
Use a source control system such as Git or SVN to share code. Eclipse supports many such systems and has extensive sharing support in the 'Team' menus.
The best way to do this would be to use source control.
Sharing the actual workspace or the files with different eclipse instance is a recipe for trouble.
An easy way to do this would be to install git on your machine and also on his machine. Eclipse actually already has git in it ready to go so you probably dont need to install anything.
The one with the files locally will create a repo locally on his computer and commit the files to it.
Next you want to init a new empty repository on a shared folder and push your local chances to this as you would to github for example.
Your partner can then git clone from this repository to his machine and work locally.
Each of you will develop on your own copy and commit your changes locally. You will share your changes by pushing your commits in that central repo and pulling from it to get changes from your partner.
You could also just open an account on GitHub, GitLab or BitBucket (there are many others too) and use that instead of a shared folder. big advantage with these services is that they will be available from anywhere.

How can I start a project on GitLab repo with Eclipse?

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.

How to merge two versions of the same project in xcode?

My colleague and I work together on an iPhone app in Xcode. Now and then, we want to merge our work. Ideally, this should also work when we are offline and use a USB stick to exchange eachother's projects.
For the case the majority of the changes are non-conflicting, what way can I use to merge these two whole projects locally, and keeping the local GIT repository in sync with these merges?
To merge the changes into your version, you need to add your colleague's version as a remote repository (although stored locally on harddisk) to your project and then pull the changes from your colleague's project into your own project.
Details:
I'm assuming you have two copies of the same Xcode project, with different changes, on your local harddisk, yours and the one with the additional changes from your colleague that you want to merge into your own version.
Moreover, I'm assuming that both of you use a local GIT repository for local version control. That's the default when you start a new Xcode project, so unsually you don't need to worry about this.
Let's assume the project folders are in these locations:
/Users/UserName/projects/YourVersion
/Users/UserName/projects/YourColleaguesVersion
For adding your colleagues project as a remote repository to your project, do this:
Go to the Organizer (click in Xcode's Menu: Window > Organizer)
Click on Repositories at the top of the Organizer window
Locate YourVersion in the list at the left side of the Organizer window
Click on "Remotes" under YourVersion
Click on "Add Remote" at the bottom of the Organizer window
In the Dialog which appeared, type in this:
Remote Name: YourColleaguesVersion
Location: file:///Users/UserName/projects/YourColleaguesVersion
Click the "Create" button and close the Organizer window
Now for pulling the changes from your colleage's project into your project, do this:
Click in Xcode's Menu: File > Source Control > Pull...
A Dialog opens and says "Choose remote from which to pull changes." - It should show YourColleaguesVersion/master as the remote repository and it should say Remote is online. Click on the "Choose" button.
You're done.
This is what source control is for. You mention git, and that's a reasonable source control system to use. git is very good at branching and merging and makes it pretty easy. You should read the git book chapter on branching. It explains it pretty well.
There are a variety of ways you can do it, but if you both work on different computers, it seems like the easiest way is to have a git server that hosts the main repository. You can each branch and merge locally or from the server. You shouldn't need to share a memory stick, though you could theoretically keep a local git repository there and each have branches on it. But git was intended to be used by many people distributed in different places each making their own frequent branches and merging them back together.
I should add that you can start a git repository locally and later move it to a server if you don't have a server right now. You can also use something like github to store your project on a server without having your own server.