suppose I have a remote repository (git@server:project.git
) with following structure:
./client
./server
And then I created a local repository in directory ~/myproject/test
using git init; git add . ; git commit -m "init check in "
. I want to push this local repository to the remote repository as a sub-directory test
paralleled with client
and server
, that is
./client
./server
./test
I wish all the check-in history in the local could be kept in the remote repository . Is there any way to achieve this? Thanks!
Simply put, a remote repository is one that is not your own. It can be another Git repository that's on your company's network, the internet, or even your local filesystem, but the point is that it's a repository distinct from your my-git-repo project.
The usual solution is to use a subtree merge strategy.
See "Git subtree merge strategy, possible without merging history?" for the details.
One other solution would be to declare your local repo as a submodule of your remote repo.
For that, you would need:
git@server:project.git
locallygit@server:test.git
as a submodule
But if your test files are closely linked to your project, that is probably not the best solution.
Previous answers did not work for me (needed more details : Git beginner here ;-), whereas https://git-scm.com/book/en/v2/Git-Tools-Submodules did it perfectly with a step-by-step approach. It also explains both methods to merge / discard history.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With