Git: How to make outer repository and embedded repository work as common/standalone repository?

前端 未结 6 1470
一生所求
一生所求 2020-12-05 09:59

I have a big project(let\'s say A repo), and it there one child folder which is come from B repo. I would meet warning like below when I commit fr

6条回答
  •  死守一世寂寞
    2020-12-05 10:25

    To elaborate more on rost shan's answer.

    I had this issue when working on a Rails application on Ubuntu 20.04.

    When I run the command git add . I get the error:

    hint: You've added another git repository inside your current repository.
    hint: Clones of the outer repository will not contain the contents of
    hint: the embedded repository and will not know how to obtain it.
    hint: If you meant to add a submodule, use:
    hint: 
    hint:   git submodule add  letsencrypt_cred
    hint: 
    hint: If you added this path by mistake, you can remove it from the
    hint: index with:
    hint: 
    hint:   git rm --cached letsencrypt_cred
    hint: 
    hint: See "git help submodule" for more information.
    

    Here's how I fixed it:

    Unstage all already staged files from git for the repo that I am trying to push to:

    git rm --cached letsencrypt_cred
    

    OR

    git rm -f --cached letsencrypt_cred (to force removal)
    

    Commit all the files that you have in your current directory:

    git commit -m "modify credentials"
    

    Add the remote repository that you want to push to:

    git remote add origin https://github.com/promisepreston/letsencrypt_cred.git
    

    Push the files to the remote repository

    git push -u origin main
    

    OR

    git push -u origin master
    

    That's all.

    I hope this helps

提交回复
热议问题