Append project to git repository using eclipse

元气小坏坏 提交于 2021-01-29 18:41:14

问题


I have remote repository which contains, some packages, and stuff basically content of package. So I want to refactor it and make new project containing some stuff from existing one. So I create new maven project to my workspace where I already imported my repository. So I add some stuff to new package and i want to push it to my remote repository. Could anyone give me a tip, or some help, I am basic eclipse user.

But when I try to share it using same local repository, then I have two projects to import but one is inside the other which I dont want. If i try to delete inner one, then project deletes.

I want my tree to look like

-.git
-proj1
-proj2

and not like

-.git
-src
-proj2
-pom.xml
-etc..

回答1:


Git manages its local operations on your system using the .git directory it creates when a project initiates git to be used. Whenever you make any changes in your project, the .git folder helps the git cli to know the status of the project and lets you perform git operations like diff, pull, push, etc.

If you move this .git folder to an empty folder, Git will interpret that you have deleted all the files from your changes. If you move it to a folder with different files, Git will again think that you have deleted the older content in your project folder and added new stuff in it i.e. Git never knows that you moved your .git folder.

Hence, you can use the above logic to achieve the same. Follow the steps below:

  1. Create an empty root folder anywhere.
  2. Move .git folder in it from the project folder. Your new root folder will contain .git folder only.
  3. Move your project's folder (proj1) to this same folder. Now your root folder will contain .git and proj1.
  4. Create your second project and move it to this folder as well. Now, your root folder will contain .git, proj1 and proj2.
  5. Then run these commands: git add ., git commit -m 'your message' and finally git push

Your done.



来源:https://stackoverflow.com/questions/61142297/append-project-to-git-repository-using-eclipse

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!