0


git 提交整个文件夹所有文件

网上对 git 提交文件夹下所有内容最多的推荐是:

  1. 把文件添加进git中: git add .
  2. 提交文件: git commit -m “提交注释”
  3. 把文件推送到git上: git push origin master

但是这个方法不是使用与所有的情况,如果想提交文件夹,并将文件夹下子文件夹的内容也提交,可能需要其他的方法。

举例:

添加在 Documentation及其子目录下,所有以 .txt 结尾的文件:

$git add Documentation/*.txt

注意,在本例中,星号 * 表示模糊匹配,或者说是全部;这使命令可以包含文档/目录子目录中的文件。

这条指令执行的结果是:在远端代码仓库创建 Documentation 文件夹(如果该文件夹不存在),并且创建 Documentation 下面,包含提交.txt后缀的子文件夹。也就是说只要子文件夹里面包含有.txt结尾的文件,该子文件夹一定会创建(如果不存在的话)。

举个例子添加涂鸦的SDK:

20190722001@V-WIN7-06-79 MINGW64 /e/project_master/components//std_old/tuya_mqtt (master)
$ tree -L 2
.
|-- CMakeLists.txt
|-- Kconfig
|-- LICENSE
|-- PortingGuide.md
|-- README.md
|-- include
| | -- atop_base.h
| | -- atop_service.h
| | -- file_download.h
| | -- matop_service.h
| | -- mqtt_bind.h
| | -- mqtt_service.h
| | -- tuya_config_defaults.h
| | -- tuya_endpoint.h
| | -- tuya_iot.h
| | -- tuya_log.h
| -- tuya_ota.h
| -- interface
| | -- http_client_interface.h
| | -- mqtt_client_interface.h
| | -- network_interface.h
| | -- storage_interface.h
| -- system_interface.h
|-- libraries
| | -- coreHTTP
| | -- coreJSON
| | -- coreMQTT
| | -- mbedtls
| -- mbedtlsFilePaths.cmake
|-- middleware
| | -- core_http_config.h
| | -- core_mqtt_config.h
| | -- http_client_wrapper.c
| | -- mqtt_client_wrapper.c
| -- transport_interface.h
|-- nwy_tuya_mqtt.c
|-- nwy_tuya_mqtt.h
|-- platform
| -- linux
|-- src
| | -- atop_base.c
| | -- atop_service.c
| | -- file_download.c
| | -- iotdns.c
| | -- matop_service.c
| | -- mqtt_bind.c
| | -- mqtt_service.c
| | -- tuya_endpoint.c
| | -- tuya_iot.c
| -- tuya_ota.c
|-- tuyaFilePaths.cmake
-- utils
| -- MultiTimer.c
| -- MultiTimer.h
| -- aes_inf.c
| -- aes_inf.h
| -- backoff_algorithm.c
| -- backoff_algorithm.h
| -- base64.c
| -- base64.h
| -- cJSON.c
| -- cJSON.h
| -- crc32.c
| -- crc32.h
| -- log.c
| -- log.h
| -- queue.h
| -- tuya_cloud_types.h
| -- tuya_error_code.h
| -- uni_md5.c
-- uni_md5.h

12 directories, 59 files

实际操作

$git add components/std_old/tuya_mqtt/*.md

$git add components/std_old/tuya_mqtt/*.c

$git add components/std_old/tuya_mqtt/*.h

$git add components/std_old/tuya_mqtt/*.txt

$git add components/std_old/tuya_mqtt/*.cmake

最后如果有Makefile,没有提交,可以再单独提交,这样就省了很多事情。

说明:涂鸦的SDK,在远端仓库代码里面并不存在,这样的提交就会直接创建tuya_mqtt该文件夹下所有的子文件夹,并提交了对应后缀的文件。

标签: git

本文转载自: https://blog.csdn.net/m0_50668851/article/details/125690227
版权归原作者 引壶觞以自酌,眄庭柯以怡颜 所有, 如有侵权,请联系我们删除。

“git 提交整个文件夹所有文件”的评论:

还没有评论