问题
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:
- Create an empty root folder anywhere.
- Move
.git
folder in it from the project folder. Your new root folder will contain.git
folder only. - Move your project's folder (proj1) to this same folder. Now your root folder will contain
.git
andproj1
. - Create your second project and move it to this folder as well. Now, your root folder will contain
.git
,proj1
andproj2
. - Then run these commands:
git add .
,git commit -m 'your message'
and finallygit push
Your done.
来源:https://stackoverflow.com/questions/61142297/append-project-to-git-repository-using-eclipse