EGit: combine two git repositories for the same project - eclipse

Scenario: Project was stored in a git repository created by EGit of Eclipse. Later on my development machine was broken. So I took the backup Eclipse project and imported it (the project, not the git repository) in a new development machine. On the new development host I created a new git repository with the imported project as the initial commit of the new git repository.The new git repository has the exactly same project name as the old one contains. Both have one branch which is the master.
So I lost the history of the commits on my old development host. Is there any way that I can combine the two with all the history from the old and new repositories? thanks

Related

How to fix the structure of the project on GitLab?

I have a problem with my project in Eclipse IDE.
For the first time, I worked on an old version and made several changes.
I tried to upload the project on GitLab for the first time I configured Git on Eclipse IDE and I tried to commit and push "but I could do that only after doing a 'Fetch' from the remote branch and commit the 'Merge' change in my local repository.
Because I got this error:
rejected non-fast-forward
I followed this link Egit rejected non-fast-forward to fix it.
The fetch downloaded all the git project files in my project on Eclipse. Until now in my project, I have a subfolder like this: myProject/myProject.
I made several commits and push and it works normally. I figured out that a subdirectory in gitLab docroot is created with every push I make.
This is the local project structure:
This is the project structure on GitLab:
I want to delete docroot/WEB-INF/classes from GitLab.
How to delete this commit from GitLab using git plugin in Eclipse and how to correct my local project structure?
docroot/WEB-INF/classes is a folder. Git does not track folders, only files:
To delete a folder, you have to delete all the files in it.
In the Git Staging view, commit the deletions.
Make sure your current local branch is configured as When pulling: Rebase (in the Git Repositories view right-click the branch and choose Configure Branch...)
Git > Pull to make sure your commit is the latest commit in the upstream branch. If there are conflicts, you have to resolve them in the Git Staging view
Git > Push to Upstream
For details see the EGit User Guide and be aware that old Stack Overflow answers refer to outdated version of EGit.

Eclipse EGit push to upstream vs push to branch

I am new to Git and GitLab. There is a GitLab (remote server) has many projects and I was asked to download "Foo_Master" branch from Project named "Foo" which is Java Maven project then do update in one of source files and push the updated file to the remote repo. So this is what I did.
I installed Eclipse IDE and EGit plugin in my local machine.
Imported Foo_Master to my local machine successfully.
Updated Java source file named "A.java".
My question is I am not sure how to commit the file to the remote repo.
Note: I saw options under Team > Repository (Please refer to a screenshot). I wonder if one of them or both would commit the file.
I realized that I should Commit first to my local repo then choose either Team > Repository > Push to Upstream or Push Branch Foo_Master to push the touched file from local to remote.

How to convert a remote branch into a local one in Eclipse using Bitbucket?

I'm kind a newbie on Bitbucket so I have a lot of doubts.
I share an Eclipse project between two different computers. I have pushed the project from one computer to the Bitbucket repository using the Eclipse plug-in. Now when I go to the other computer I have fetched the repository that is saved on Bitbucket, and it has created a new remote tracking branch on my Eclipse local repository.
My problem comes when I want to merge that branch with the local branch, I have no idea how can I do that
Anyone could help me?
ps: sorry if the problem or the situation is not very clear
You should follow the section "Pulling New Changes from Upstream Branch ":
a git pull is a fetch + a merge.
Right-click on a project in the Package Explorer and select Team > Pull or right-click on a repository in the Git Repositories view and select Pull to pull new changes from the upstream branch your local branch is tracking.
The section "Fetch and Pull" of the Egit tutorial says as much:
When cloning remote repositories, Git creates copies of the branches as local branches and as remote branches.
A Fetch operation will update the remote branches only.
To update your local branches as well, you will have to perform a Merge operation after fetching.

Egit push doesn't change files in remote repository

I came to know about the git / egit version control system last week, seems too good to be true .So thought to shift from SVN to git..Since last week I am trying to understand the basics and concepts of git.
So I created a test environment for understanding the workflow of egit in eclipse as following.
I am following the strategy of remote tracking there are two repositories named local and remote used for understanding the workflow.
I created a repository named 'remote' with an emtpy index.php file and has one master branch and imported the project into eclipse.
I created another git repository named 'local' by cloning the above 'remote' git repo, this repository is now tracked by 'remote' repository has one master branch and origin/master remote tracking branch.
I imported the project from 'local' git repo. into my eclipse workbench and changed the index.php file using eclipse php editor -> committed changes to local's master branch and -> performed push from local master branch.
When checking the remote working directory .. there is no change updated which I did in local's index.php file , however master branch in the remote repository view shows the latest commit which I committed in the local's master branch, but unfortunately files are not updated, it just adds asterisk mark to all changed files in my remote project view.
So researching about the asterisk mark I found its in staged condition .So can anyone lead me to the right way explaining how to successfully perform push operation from local's master branch to remote's branch I will be grateful.
this is the picture of my egit test case set up in eclipse for understanding the workflow. you can see the asterisk mark in the remote project after performing push from local repository,you can see all three branches viz.local's master, origin/master and remote's master branches shows same latest commit.
1
Thank You.
I tried using bare repo. as a remote, when I push from changes from local to remote, I don't find any files in remote repo. Just branch gets updated with the latest commit.
That seems normal, since a bare repo has *no working tree, meaning no files.
You would need to clone that remote repo, and add this cloned repo (non-bare) as a project in your Eclipse, in order to:
push from your first Egit-managed repo to the bare remote repo
pull from that same bare repo to your second Egit-managed non-bare repo.

egit for eclipse: How do I put my existing project in the clone of my buddies repo?

My buddy gave me his git address for the project we are going to work on. In Eclipse using egit I cloned his branch.
So now in my Git view I have my own repository I created of an existing project. I want this existing project to be on my buddies branch so we can both check it out and have it in our repo.
Unfortunately I am using Windows to do this because we are developing a game and I do all of the art & animation in addition to programming. I would feel much more comfortable on the cmd line than using this plugin..
Any help is much appreciated!
The notion of repo and branch are quite different.
If you have a clone of our buddy's repo, you can work on a branch named like the one your buddy uses (by default 'master' if he hadn't created any other), and everything you will push will be added/merged to the remote branch in the remote repo.
For more on Egit, see this "Git with Eclipse (EGit) - Tutorial", and check if yuo can push at least one file, that your colleague will be able to pull from the remote repo and see directly in his branch.