Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I have a program divided into 3 packages. I have set up a local repo in one of the packages and set it up to push to a repo on gitHub. I have started work on the second package and I realized I haven't initialized it with git. I wanted to use the same gitHub repo to push the second package to but I'm not sure it will work since I have already set up my first package to push to it. I think I should have done git init on the parent folder of the three packages and then the folder/package structure would have shown up on my gitHub repo. Is there a simple way to fix this? Thanks!

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
213 views
Welcome To Ask or Share your Answers For Others

1 Answer

Let's say your parent directory is named parent, and your child directories are named package1, package2, and package3. Let's also assume that package1 is the directory where you have your git repository. I would just make another package1 directory as a child of the original package1 directory, and move the contents of the original package1 directory into it. Then move package2 and package3 to be children of the original package1. You can the rename the original package1 to parent. git add --all . the whole thing, and you now have a repo with all three directories. The cool thing is that you will not lose the history of all the files you moved; git is smart enough to detect renames/moves.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...