Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
222 views
in Technique[技术] by (71.8m points)

github - I need git to include the parent directory

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

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

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...