编程知识 cdmana.com

Git sub warehouse management (add sub warehouse, delete sub warehouse, update sub warehouse)

background

Modules maintained by others are often used in projects , stay git Using the function of sub module in can greatly improve the development efficiency .

After using the sub module , You don't have to be responsible for the maintenance of sub modules , Just update the sub modules synchronously when necessary .

For example, a code base that uses a sub warehouse , How to get the content of its sub warehouse ?

git clone [email protected]:maomaocn/git_submodule.git
cd git_submodule/
git submodule init
git submodule update

If black adds a sub warehouse ?

git submodule add [email protected]:maomaocn/Django-EPR-python3.git

How to delete a sub warehouse ?

# Delete submodule cache 
git add .gitmodules  
git rm --cached submodule_name
# Delete submodule Catalog 
rm -rf submodule_name
# modify .gitmodules
# Remove the corresponding submodule Information ,  Only 1 individual submodule Information can also delete the file 
vi .gitmodules 
 See the following :
[submodule "DRFDemo"]
	path = DRFDemo
	url = [email protected]:maomaocn/DRFDemo.git

 Delete the corresponding information 
cd .git/modules 
rm -rf DRFDemo

vi .git/config
# Remove the corresponding submodule Information 

Execute the command of adding sub warehouse again .

git submodule add [email protected]:maomaocn/DRFDemo.git

版权声明
本文为[love_ 521_]所创,转载请带上原文链接,感谢
https://cdmana.com/2022/134/202205141345577653.html

Scroll to Top