I cloned a github repo into my repo (let's say https://github.com/foo/bar.git
) to my local git hepo. After doing git add -A
, I see that git only created my_repo/bar/
directory, but didn't add its content ... when I do a push to my github repo, the bar
directory is empty. How can I add the content of the bar
repo into my repo? PS: I'm not trying to steal someone's code, it's because the entire project has to go together and bar
is a dependence.
Git won't track files of another repository inside yours. There are two solutions:
Clone the repository and delete the .git
directory of the clone repository. The cloned repository will be part of your code, not a local repository anymore. You will not push or pull anything to the other repository.
Go with Git submodules . I think it is a better way:
git submodule add https://github.com/foo/bar.git bar_local_dir
Try downloading the source code and copy it to the local git repo . Once you have done this , then push the code with your changes to your github repo.
This is what i interfere from your description.
What you can do (but a submodule is probably a better way) is the following:
Better experiment on copies, doing this can screw up things badly...
(I did something similar when I squashed notes for two courses into one set of notes. Took me something like a full day until I was convinced nothing had gone missing. Not recommended for everyday use...)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.