Downloading a second repository to a project

Answered

I have 2 projects locally, A and B

Project A contains a file "a.txt"

Project B contains a file "b.txt"

Both projects are imported to Version Control  and shared on Github (private)

Now, Project A likes to download Project B so that Project A now will host two files, "a.txt" and "b.txt". Question 1: How do I "download" Project B "into" Project A?

I push Project A to Github so the file "b.txt" is now in Github repo "A"

In Project A I make changes in file "b.txt", I push it to repo A at Github

I now like to push my imported Project B back to GitHub so that my changes in file "b.txt"  Question 2: How do I push files that belong to Project B back to Project B on Github?

 

0
1 comment

Why do you want to duplicate file in both repositories? You can simply use Project B as a nested repository, or use git submodules.

Moreover, IntelliJ works with all repositories in the project, so if the same file is tracked in both repositories, its status can be determined iincorrectly and the file may be committed to a wrong repository.

To answer your question:

> How do I "download" Project B "into" Project A?

Just clone the project B from its repo to the Project A fodler

> How do I push files that belong to Project B back to Project B on Github?

You first need to commit the changes you did to the file to Project B as well. it might not work in IntelliJ because it will get the status of the file from the Project A repo and report the file as not modified. Refreshing local history might help, but even if the file is listed as modified, the repo it belongs to will likely be determined as Project A.

If you somehow commit the change to the Project B though (e.g. via command line), you will be able to just use Push dialog - it will show both repositories you have and allow to push from both.

I do not recommend using such setup though, as IntelliJ is not designed to support this. Consider using a simple nested repo, or submodule.

0

Please sign in to leave a comment.