J
J
Jirafek2021-11-28 11:39:04
git
Jirafek, 2021-11-28 11:39:04

How to use someone else's repository in your own?

I have my repository (A) and I clone another user's repository (B) into my repo. And if I want to change repository B, then git swears and does not allow me to do this. Colonized with (git clone)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergio, 2021-11-28
@Jirafek

There are 3 options:
1. Add a third-party repository as a submodule:
git submodule add B_repo_url
This method is suitable if you do not want to store third-party code in your repository or split your repository into several different repositories (modules).
When cloning to another machine, you will need to add the --recursive flag to the "git clone" command to clone all code, including submodules.
git clone repo_A_url --recursive
or

git clone repo_A_url && git submodule update --init

2. Copy the code of a third-party repository to your repository (partially or completely) and place it in a subfolder of yours, for example, external/B
This option is suitable if the third-party repository is not available via Git or you are calmer when all the code is in your repository, and not where -something there.
3. Add as a "subtree" via git-subtree
git-subtree is something between the first two - the code will be copied into your repository from a third party repository, but you can automatically pull changes to a third party repository via git subtree pull, just like with submodules (i.e. you don't have to manually copy the code with a new release).

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question