Jump to content

Eclipse egit - Project synced with two git repositories

Claryn

Hi.

I am in a Java OOP class where we use Eclipse and egit. We have a repository where the lecturers share projects with us, from his own GitHub repositories. One of these Java-projects are supposed to used in this way:

Exercises are published to the project, so we pull them form his repositories. The projects also includes jTests and jExercises, also a lot of classes necessary to do the exercises. However, we are supposed to make our own classes in his repository (without pushing anything - we dont have access anyways).

Now, I want to also sync the exercise project with my own GitHub repository so I can keep it for late reference. How can I do that in Eclipse?

Running Arch with i3-gaps on a Thinkpad X1 Extreme
Data Science Postgrad

 

Link to comment
Share on other sites

Link to post
Share on other sites

7 hours ago, SCHISCHKA said:

 http://wiki.eclipse.org/EGit/User_Guide#Push_Upstream

i think you are looking for this. Clone your teachers git and then push it to your own

I ran into a couple of issues:

It wont let me add another branch - and even if I did, they would be identical for the two repositories (refs/heads/master). 


I have confirmed that the repository that I pull from is read-only. What would work for me is to keep the Pull-stream to the lecturer's repository, but change the Push-stream to my own repository. However, under Remotes-origin, if I change one of them, both changes. 

 

Edit: And whenever I try to push to my personal repos. when I changed the Remotes on the projects that I got from the lecturer's repos., I get a "rejected - non-fast-forward" error. 

Edit2: I got it to push, finally. However, I have two different branches. Is there a way to merge them, so that all the projects (mine that are NOT in the lecturer's repos., and the lecturer's) in one single branch?

Running Arch with i3-gaps on a Thinkpad X1 Extreme
Data Science Postgrad

 

Link to comment
Share on other sites

Link to post
Share on other sites

47 minutes ago, Claryn said:

I ran into a couple of issues:

It wont let me add another branch - and even if I did, they would be identical for the two repositories (refs/heads/master). 


I have confirmed that the repository that I pull from is read-only. What would work for me is to keep the Pull-stream to the lecturer's repository, but change the Push-stream to my own repository. However, under Remotes-origin, if I change one of them, both changes. 

 

Edit: And whenever I try to push to my personal repos. when I changed the Remotes on the projects that I got from the lecturer's repos., I get a "rejected - non-fast-forward" error. 

Edit2: I got it to push, finally. However, I have two different branches. Is there a way to merge them, so that all the projects (mine that are NOT in the lecturer's repos., and the lecturer's) in one single branch?

https://wiki.eclipse.org/EGit/User_Guide#Removing_Repositories

another thing you can do is just delete all git files manually after cloning

             ☼

ψ ︿_____︿_ψ_   

Link to comment
Share on other sites

Link to post
Share on other sites

1 minute ago, Claryn said:

Either way, this comment was very unnecessary and non-constructive.

In your limited view perhaps. I'd suggested it to you since it is the superior IDE for Java and it also has excellent Git integration.

2 hours ago, Claryn said:

we use a version of Eclipse that is modified to work with this course

In what way(s) specifically?

The single biggest problem in communication is the illusion that it has taken place.

Link to comment
Share on other sites

Link to post
Share on other sites

38 minutes ago, Nuluvius said:

In your limited view perhaps. I'd suggested it to you since it is the superior IDE for Java and it also has excellent Git integration.

In what way(s) specifically?

We are using custom .setup files from the institution that has the course that allows them to push Eclipse-extensions to us that they have made themselves to work with some of the micro-controllers we are using. These are Atmel-based controllers (Atmel is designed in Trondheim, Norway - at the university I study at), and the extensions we need are custom, so only Eclipse will do. 

If you didnt know, Atmel powers stuff like the Arduino UNO. 

Running Arch with i3-gaps on a Thinkpad X1 Extreme
Data Science Postgrad

 

Link to comment
Share on other sites

Link to post
Share on other sites

1 hour ago, SCHISCHKA said:

https://wiki.eclipse.org/EGit/User_Guide#Removing_Repositories

another thing you can do is just delete all git files manually after cloning

I managed to get some stuff working myself: 

 

I managed to make it so that I had separate Push and Pull repositories. It worked fine, and I made it so that I only have one branch in MY repos., and then I just place all of my own projects there as well.

 

The problem I am facing now is that I cannot really sync between more than 1 device. All this current solution does is sync with GitHub. if I were to install Eclipse on another machine and try to Pull my repos. (with my code, AND the lecturer's code), I wouldn't be able to pull updates from the lecturer (which adds new projects every day). Do you see the problem?

 

 

Running Arch with i3-gaps on a Thinkpad X1 Extreme
Data Science Postgrad

 

Link to comment
Share on other sites

Link to post
Share on other sites

i think you want rebasing which is directly after the branching section

https://wiki.eclipse.org/EGit/User_Guide#Branching

Quote

Rebasing

Rebase Introduction

Rebase applies a chain of commits onto a given commit. A typical scenario is the development of some feature on a "topic" branch which was created from a "master" branch at some point in time. When "master" is updated with changes e.g. from other developers while "topic" is still under development, it may become necessary to incorporate these changes into "topic".

Let's assume we start development on "topic" by creating the "topic" branch from master. At this point, both "master" and "topic" point to commit "E". When the first commit ("A") is added to "topic", the commit history of the repository looks like this:


          A topic
         /
    D---E master

Now, let's assume that there were some more commits on "topic" and as well some more commits on "master" (for example, "master" may track some remote repository and there were some changes in that remote repository that have been pulled into "master"):


          A---B---C topic
         /
    D---E---F---G master

Now, in order to incorporate the changes in "master" into "topic", a Rebase of "topic" onto "master" would produce


                  A'--B'--C' topic
                 /
    D---E---F---G master


Technically, the sequence of commits that are contained in "topic" but not in "master" are applied (that is, cherry-picked) on top of "master" one by one.

Note that the commits A, B, C are neither lost nor changed, instead a new chain of commits A', B', C' with the same changes and commit messages as the original commits (but different commit IDs) will be created. The old commits A, B, C are still around in the object database but not visible anymore as they are no longer reachable from any branch. A', B', C' are different from the old ones as they now also contain changes F and G.

 

             ☼

ψ ︿_____︿_ψ_   

Link to comment
Share on other sites

Link to post
Share on other sites

1 hour ago, SCHISCHKA said:

i think you want rebasing which is directly after the branching section

https://wiki.eclipse.org/EGit/User_Guide#Branching

 

Im sorry but I am not familiar enough with git to make any sense of how this works. I have tried reading some documentation on this, also some videos, but I end up in a rabbit-whole of having to read up on other terminology and functions in git that I have no idea how to use. 

I dont even have a good understand of what a branch is or how they work. All I know is who to create a repository, how to commit to it, and how to pull from it. 

 

What I need now is a way to be able to pull files from a remote repository 1, add my own files to the files I pull from repository 1, and be able to push them to my own remote repository 2. I also need that to be doable from several machines, where any machine can get the newest files from both repository 1 and 2. 

 

Note that repository 1 and 2 are organised in such a way that there are never going to be duplicate files you PULL from repository 1 with the ones I supplement to repository 2. 

Running Arch with i3-gaps on a Thinkpad X1 Extreme
Data Science Postgrad

 

Link to comment
Share on other sites

Link to post
Share on other sites

18 minutes ago, Claryn said:

Im sorry but I am not familiar enough with git to make any sense of how this works. I have tried reading some documentation on this, also some videos, but I end up in a rabbit-whole of having to read up on other terminology and functions in git that I have no idea how to use. 

I dont even have a good understand of what a branch is or how they work. All I know is who to create a repository, how to commit to it, and how to pull from it. 

 

What I need now is a way to be able to pull files from a remote repository 1, add my own files to the files I pull from repository 1, and be able to push them to my own remote repository 2. I also need that to be doable from several machines, where any machine can get the newest files from both repository 1 and 2. 

 

Note that repository 1 and 2 are organised in such a way that there are never going to be duplicate files you PULL from repository 1 with the ones I supplement to repository 2. 

 

 

Alright, I think I understand this now:

I have the master-branch which is the "production" version of the repos. It is the one that all my devices will see. If I create a new branch "add-new-feature", it copies the master-branch over, and lets me work on a separate version of the master-branch. 

 

When I rebase, I add the changes I did in the add-new-feature branch to the master-branch without messing up any of the changes done there (to other files). Right. 

 

So whenever I want to work in another device, I just create a new branch, do the work, then I rebase that branch back into the master-branch?
Now, is there a way I can do this with eGit in Eclipse, or will I have to rely on the terminal?
 

Running Arch with i3-gaps on a Thinkpad X1 Extreme
Data Science Postgrad

 

Link to comment
Share on other sites

Link to post
Share on other sites

2 minutes ago, Claryn said:

Alright, I think I understand this now:

I have the master-branch which is the "production" version of the repos. It is the one that all my devices will see. If I create a new branch "add-new-feature", it copies the master-branch over, and lets me work on a separate version of the master-branch. 

 

When I rebase, I add the changes I did in the add-new-feature branch to the master-branch without messing up any of the changes done there (to other files). Right. 

 

So whenever I want to work in another device, I just create a new branch, do the work, then I rebase that branch back into the master-branch?
Now, is there a way I can do this with eGit in Eclipse, or will I have to rely on the terminal?

pretty much; clone on each device, branch and commit/push the branch to your remote git on each machine. When you want to get updates from your teacher, pull & rebase. 

I stopped using eclipse a while ago so I cannot confirm how to do this through the GUI. eGit would be incomplete if it could not branch, thats a pretty important function of git and I'm very confident in my guess that it can do what you want

             ☼

ψ ︿_____︿_ψ_   

Link to comment
Share on other sites

Link to post
Share on other sites

1 minute ago, SCHISCHKA said:

pretty much; clone on each device, branch and commit/push the branch to your remote git on each machine. When you want to get updates from your teacher, pull & rebase. 

I stopped using eclipse a while ago so I cannot confirm how to do this through the GUI. eGit would be incomplete if it could not branch, thats a pretty important function of git and I'm very confident in my guess that it can do what you want

It seems like I can do it from the GUI. TBH I feel more confident using the terminal for this. 

One thing I dont understand is how I can go to the terminal, create a new branch in the git repos., and it instantly shows up in Eclipse. I then do a change to a file and commit it using the terminal, then I rebase with master and push to origin (remote), and there it is! master is updated on github.com. magic.

 

Running Arch with i3-gaps on a Thinkpad X1 Extreme
Data Science Postgrad

 

Link to comment
Share on other sites

Link to post
Share on other sites

5 minutes ago, Claryn said:

It seems like I can do it from the GUI. TBH I feel more confident using the terminal for this. 

One thing I dont understand is how I can go to the terminal, create a new branch in the git repos., and it instantly shows up in Eclipse. I then do a change to a file and commit it using the terminal, then I rebase with master and push to origin (remote), and there it is! master is updated on github.com. magic.

 

Just make all of this clear for me:

I should still PULL from lecturer's repos. and PUSH to my own repos.? Before I push I should 

1. Pull updates from lecturer

2. Rebrand my branch to master

3. Push to my own repos.


Is this correct?

Running Arch with i3-gaps on a Thinkpad X1 Extreme
Data Science Postgrad

 

Link to comment
Share on other sites

Link to post
Share on other sites

3 minutes ago, Claryn said:

Just make all of this clear for me:

I should still PULL from lecturer's repos. and PUSH to my own repos.? Before I push I should 

1. Pull updates from lecturer

2. Rebrand my branch to master

3. Push to my own repos.


Is this correct?

No I still cant get this to work. I am now on my other machine, testing this out.

 

If I want to PULL from my lecturer, I wont be getting my own updates. If I want to pull from MY repos, I wont be getting lecturers updates. 

 

Running Arch with i3-gaps on a Thinkpad X1 Extreme
Data Science Postgrad

 

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×