【git】报错error: src refspec release/web3.1 does not match any

解决Git提交代码时遇到的问题

git提交代码报错问题解决

现象
在这里插入图片描述

解决思路
利用git add xxx.py 指令,将所有的文件全部都添加,然后再进行git commit -m "init"将所有的文件commit,

  1. 命令行提交:git commit -m ‘init’
  2. 远程添加 : git remote add origin XXXX.git
  3. 最后使用push提交: git push -u origin (本地分支):(远程峰值)
tao@tao:~/SLAM/ORB_SLAM3/build$ cmake .. -DCMAKE_BUILD_TYPE=Release -DOPENCV_VERSION=3.4 2>&1 | tee cmake.log CMake Deprecation Warning at CMakeLists.txt:1 (cmake_minimum_required): Compatibility with CMake < 3.10 will be removed from a future version of CMake. Update the VERSION argument <min> value. Or, use the <min>...<max> syntax to tell CMake that the project requires at least <min> but has been updated to work with policies introduced by <max> or earlier. -- The C compiler identification is GNU 7.5.0 -- The CXX compiler identification is GNU 9.4.0 -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Check for working C compiler: /usr/bin/cc - skipped -- Detecting C compile features -- Detecting C compile features - done -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Check for working CXX compiler: /usr/bin/c++ - skipped -- Detecting CXX compile features -- Detecting CXX compile features - done Build type: Release -- Performing Test COMPILER_SUPPORTS_CXX11 -- Performing Test COMPILER_SUPPORTS_CXX11 - Success -- Performing Test COMPILER_SUPPORTS_CXX0X -- Performing Test COMPILER_SUPPORTS_CXX0X - Success -- Using flag -std=c++11. -- Found OpenCV: /usr/local (found suitable version "4.2.0", minimum required is "4.2") OPENCV VERSION: 4.2.0 CMake Deprecation Warning at /usr/lib/x86_64-linux-gnu/cmake/pcl/PCLConfig.cmake:40 (cmake_policy): Compatibility with CMake < 3.10 will be removed from a future version of CMake. Update the VERSION argument <min> value. Or, use the <min>...<max> syntax to tell CMake that the project requires at least <min> but has been updated to work with policies introduced by <max> or earlier. Call Stack (most recent call first): CMakeLists.txt:41 (find_package) CMake Warning (dev) at /usr/lib/x86_64-linux-gnu/cmake/pcl/PCLConfig.cmake:152 (find_package): Policy CMP0144 is not set: find_package uses upper-case <PACKAGENAME>_ROOT variables. Run "cmake --help-policy CMP0144" for policy details. Use the cmake_policy command to set the policy and suppress this warning. CMake variable EIGEN_ROOT is set to: /usr/include/eigen3 For compatibility, find_package is ignoring the variable, but code in a .cmake module might still use it. Call Stack (most recent call first): /usr/lib/x86_64-linux-gnu/cmake/pcl/PCLConfig.cmake:316 (find_eigen) /usr/lib/x86_64-linux-gnu/cmake/pcl/PCLConfig.cmake:551 (find_external_library) CMakeLists.txt:41 (find_package) This warning is for project developers. Use -Wno-dev to suppress it. -- Checking for module &#39;eigen3&#39; -- Found eigen3, version 3.3.7 -- Found Eigen: /usr/include/eigen3 (Required is at least version "3.1") -- Eigen found (include: /usr/include/eigen3, version: 3.3.7) CMake Warning (dev) at /usr/lib/x86_64-linux-gnu/cmake/pcl/PCLConfig.cmake:134 (find_package): Policy CMP0167 is not set: The FindBoost module is removed. Run "cmake --help-policy CMP0167" for policy details. Use the cmake_policy command to set the policy and suppress this warning. Call Stack (most recent call first): /usr/lib/x86_64-linux-gnu/cmake/pcl/PCLConfig.cmake:314 (find_boost) /usr/lib/x86_64-linux-gnu/cmake/pcl/PCLConfig.cmake:551 (find_external_library) CMakeLists.txt:41 (find_package) This warning is for project developers. Use -Wno-dev to suppress it. -- Found Boost: /usr/include (found suitable version "1.71.0", minimum required is "1.55.0") found components: system filesystem date_time iostreams regex -- Checking for module &#39;libusb-1.0&#39; -- Found libusb-1.0, version 1.0.23 CMake Warning (dev) at /usr/local/share/cmake-3.31/Modules/FindPackageHandleStandardArgs.cmake:441 (message): The package name passed to `find_package_handle_standard_args` (USB_10) does not match the name of the calling package (OpenNI). This can lead to problems in calling code that expects `find_package` result variables (e.g., `_FOUND`) to follow a certain pattern. Call Stack (most recent call first): /usr/lib/x86_64-linux-gnu/cmake/pcl/Modules/FindOpenNI.cmake:28 (find_package_handle_standard_args) /usr/lib/x86_64-linux-gnu/cmake/pcl/PCLConfig.cmake:179 (find_package) /usr/lib/x86_64-linux-gnu/cmake/pcl/PCLConfig.cmake:322 (find_openni) /usr/lib/x86_64-linux-gnu/cmake/pcl/PCLConfig.cmake:548 (find_external_library) CMakeLists.txt:41 (find_package) This warning is for project developers. Use -Wno-dev to suppress it. -- Found USB_10: /usr/lib/x86_64-linux-gnu/libusb-1.0.so -- Found OpenNI: /usr/lib/libOpenNI.so -- OpenNI found (include: /usr/include/ni, lib: /usr/lib/libOpenNI.so) CMake Warning (dev) at /usr/local/share/cmake-3.31/Modules/FindPackageHandleStandardArgs.cmake:441 (message): The package name passed to `find_package_handle_standard_args` (USB_10) does not match the name of the calling package (OpenNI2). This can lead to problems in calling code that expects `find_package` result variables (e.g., `_FOUND`) to follow a certain pattern. Call Stack (most recent call first): /usr/lib/x86_64-linux-gnu/cmake/pcl/Modules/FindOpenNI2.cmake:28 (find_package_handle_standard_args) /usr/lib/x86_64-linux-gnu/cmake/pcl/PCLConfig.cmake:193 (find_package) /usr/lib/x86_64-linux-gnu/cmake/pcl/PCLConfig.cmake:324 (find_openni2) /usr/lib/x86_64-linux-gnu/cmake/pcl/PCLConfig.cmake:548 (find_external_library) CMakeLists.txt:41 (find_package) This warning is for project developers. Use -Wno-dev to suppress it. -- Found OpenNI2: /usr/lib/libOpenNI2.so -- OpenNI2 found (include: /usr/include/openni2, lib: /usr/lib/libOpenNI2.so) ** WARNING ** io features related to pcap will be disabled ** WARNING ** io features related to png will be disabled -- The imported target "vtkParseOGLExt" references the file "/usr/bin/vtkParseOGLExt-7.1" but this file does not exist. Possible reasons include: * The file was deleted, renamed, or moved to another location. * An install or uninstall procedure did not complete successfully. * The installation package was faulty and contained "/usr/lib/cmake/vtk-7.1/VTKTargets.cmake" but not all the files it references. -- The imported target "vtkRenderingPythonTkWidgets" references the file "/usr/lib/x86_64-linux-gnu/libvtkRenderingPythonTkWidgets.so" but this file does not exist. Possible reasons include: * The file was deleted, renamed, or moved to another location. * An install or uninstall procedure did not complete successfully. * The installation package was faulty and contained "/usr/lib/cmake/vtk-7.1/VTKTargets.cmake" but not all the files it references. -- The imported target "vtk" references the file "/usr/bin/vtk" but this file does not exist. Possible reasons include: * The file was deleted, renamed, or moved to another location. * An install or uninstall procedure did not complete successfully. * The installation package was faulty and contained "/usr/lib/cmake/vtk-7.1/VTKTargets.cmake" but not all the files it references. -- The imported target "pvtk" references the file "/usr/bin/pvtk" but this file does not exist. Possible reasons include: * The file was deleted, renamed, or moved to another location. * An install or uninstall procedure did not complete successfully. * The installation package was faulty and contained "/usr/lib/cmake/vtk-7.1/VTKTargets.cmake" but not all the files it references. CMake Warning (dev) at /usr/local/share/cmake-3.31/Modules/FindPackageHandleStandardArgs.cmake:441 (message): The package name passed to `find_package_handle_standard_args` (libusb-1.0) does not match the name of the calling package (PCL). This can lead to problems in calling code that expects `find_package` result variables (e.g., `_FOUND`) to follow a certain pattern. Call Stack (most recent call first): /usr/lib/x86_64-linux-gnu/cmake/pcl/PCLConfig.cmake:291 (find_package_handle_standard_args) /usr/lib/x86_64-linux-gnu/cmake/pcl/PCLConfig.cmake:338 (find_libusb) /usr/lib/x86_64-linux-gnu/cmake/pcl/PCLConfig.cmake:548 (find_external_library) CMakeLists.txt:41 (find_package) This warning is for project developers. Use -Wno-dev to suppress it. -- Found libusb-1.0: /usr/include ** WARNING ** io features related to libusb-1.0 will be disabled -- looking for PCL_COMMON CMake Warning (dev) at /usr/local/share/cmake-3.31/Modules/FindPackageHandleStandardArgs.cmake:441 (message): The package name passed to `find_package_handle_standard_args` (PCL_COMMON) does not match the name of the calling package (PCL). This can lead to problems in calling code that expects `find_package` result variables (e.g., `_FOUND`) to follow a certain pattern. Call Stack (most recent call first): /usr/lib/x86_64-linux-gnu/cmake/pcl/PCLConfig.cmake:616 (find_package_handle_standard_args) CMakeLists.txt:41 (find_package) This warning is for project developers. Use -Wno-dev to suppress it. -- Found PCL_COMMON: /usr/lib/x86_64-linux-gnu/libpcl_common.so -- looking for PCL_OCTREE CMake Warning (dev) at /usr/local/share/cmake-3.31/Modules/FindPackageHandleStandardArgs.cmake:441 (message): The package name passed to `find_package_handle_standard_args` (PCL_OCTREE) does not match the name of the calling package (PCL). This can lead to problems in calling code that expects `find_package` result variables (e.g., `_FOUND`) to follow a certain pattern. Call Stack (most recent call first): /usr/lib/x86_64-linux-gnu/cmake/pcl/PCLConfig.cmake:616 (find_package_handle_standard_args) CMakeLists.txt:41 (find_package) This warning is for project developers. Use -Wno-dev to suppress it. -- Found PCL_OCTREE: /usr/lib/x86_64-linux-gnu/libpcl_octree.so -- looking for PCL_IO CMake Warning (dev) at /usr/local/share/cmake-3.31/Modules/FindPackageHandleStandardArgs.cmake:441 (message): The package name passed to `find_package_handle_standard_args` (PCL_IO) does not match the name of the calling package (PCL). This can lead to problems in calling code that expects `find_package` result variables (e.g., `_FOUND`) to follow a certain pattern. Call Stack (most recent call first): /usr/lib/x86_64-linux-gnu/cmake/pcl/PCLConfig.cmake:616 (find_package_handle_standard_args) CMakeLists.txt:41 (find_package) This warning is for project developers. Use -Wno-dev to suppress it. -- Found PCL_IO: /usr/lib/x86_64-linux-gnu/libpcl_io.so -- Found PCL: pcl_common;pcl_octree;pcl_io;/usr/local/lib/libboost_system.so;/usr/local/lib/libboost_filesystem.so;/usr/local/lib/libboost_date_time.so;/usr/local/lib/libboost_iostreams.so;/usr/local/lib/libboost_regex.so;/usr/lib/libOpenNI.so;/usr/lib/libOpenNI2.so;vtkChartsCore;vtkCommonColor;vtkCommonCore;vtksys;vtkCommonDataModel;vtkCommonMath;vtkCommonMisc;vtkCommonSystem;vtkCommonTransforms;vtkCommonExecutionModel;vtkFiltersGeneral;vtkCommonComputationalGeometry;vtkFiltersCore;vtkInfovisCore;vtkFiltersExtraction;vtkFiltersStatistics;vtkImagingFourier;vtkImagingCore;vtkalglib;vtkRenderingContext2D;vtkRenderingCore;vtkFiltersGeometry;vtkFiltersSources;vtkRenderingFreeType;/usr/lib/x86_64-linux-gnu/libfreetype.so;/usr/lib/x86_64-linux-gnu/libz.so;vtkFiltersModeling;vtkImagingSources;vtkInteractionStyle;vtkInteractionWidgets;vtkFiltersHybrid;vtkImagingColor;vtkImagingGeneral;vtkImagingHybrid;vtkIOImage;vtkDICOMParser;vtkmetaio;/usr/lib/x86_64-linux-gnu/libjpeg.so;/usr/lib/x86_64-linux-gnu/libpng.so;/usr/lib/x86_64-linux-gnu/libtiff.so;vtkRenderingAnnotation;vtkRenderingVolume;vtkIOXML;vtkIOCore;vtkIOXMLParser;/usr/lib/x86_64-linux-gnu/libexpat.so;vtkIOGeometry;vtkIOLegacy;vtkIOPLY;vtkRenderingLOD;vtkViewsContext2D;vtkViewsCore;vtkRenderingContextOpenGL2;vtkRenderingOpenGL2 (Required is at least version "1.10") CMake Warning at CMakeLists.txt:44 (find_package): By not providing "Findrealsense2.cmake" in CMAKE_MODULE_PATH this project has asked CMake to find a package configuration file provided by "realsense2", but CMake did not find one. Could not find a package configuration file provided by "realsense2" with any of the following names: realsense2Config.cmake realsense2-config.cmake Add the installation prefix of "realsense2" to CMAKE_PREFIX_PATH or set "realsense2_DIR" to a directory containing one of the above files. If "realsense2" provides a separate development package or SDK, be sure it has been installed. CMake Deprecation Warning at Thirdparty/g2o/CMakeLists.txt:1 (CMAKE_MINIMUM_REQUIRED): Compatibility with CMake < 3.10 will be removed from a future version of CMake. Update the VERSION argument <min> value. Or, use the <min>...<max> syntax to tell CMake that the project requires at least <min> but has been updated to work with policies introduced by <max> or earlier. -- BUILD TYPE:Release -- Compiling on Unix -- Found OpenMP_C: -fopenmp (found version "4.5") -- Found OpenMP_CXX: -fopenmp (found version "4.5") -- Found OpenMP: TRUE (found version "4.5") -- PCL_INCLUDE_DIRS = /usr/include/pcl-1.10;/usr/include/eigen3;/usr/include;/usr/include/ni;/usr/include/openni2;/usr/include/vtk-7.1;/usr/include/freetype2;/usr/include/x86_64-linux-gnu -- PCL_LIBRARIES = pcl_common;pcl_octree;pcl_io;/usr/local/lib/libboost_system.so;/usr/local/lib/libboost_filesystem.so;/usr/local/lib/libboost_date_time.so;/usr/local/lib/libboost_iostreams.so;/usr/local/lib/libboost_regex.so;/usr/lib/libOpenNI.so;/usr/lib/libOpenNI2.so;vtkChartsCore;vtkCommonColor;vtkCommonCore;vtksys;vtkCommonDataModel;vtkCommonMath;vtkCommonMisc;vtkCommonSystem;vtkCommonTransforms;vtkCommonExecutionModel;vtkFiltersGeneral;vtkCommonComputationalGeometry;vtkFiltersCore;vtkInfovisCore;vtkFiltersExtraction;vtkFiltersStatistics;vtkImagingFourier;vtkImagingCore;vtkalglib;vtkRenderingContext2D;vtkRenderingCore;vtkFiltersGeometry;vtkFiltersSources;vtkRenderingFreeType;/usr/lib/x86_64-linux-gnu/libfreetype.so;/usr/lib/x86_64-linux-gnu/libz.so;vtkFiltersModeling;vtkImagingSources;vtkInteractionStyle;vtkInteractionWidgets;vtkFiltersHybrid;vtkImagingColor;vtkImagingGeneral;vtkImagingHybrid;vtkIOImage;vtkDICOMParser;vtkmetaio;/usr/lib/x86_64-linux-gnu/libjpeg.so;/usr/lib/x86_64-linux-gnu/libpng.so;/usr/lib/x86_64-linux-gnu/libtiff.so;vtkRenderingAnnotation;vtkRenderingVolume;vtkIOXML;vtkIOCore;vtkIOXMLParser;/usr/lib/x86_64-linux-gnu/libexpat.so;vtkIOGeometry;vtkIOLegacy;vtkIOPLY;vtkRenderingLOD;vtkViewsContext2D;vtkViewsCore;vtkRenderingContextOpenGL2;vtkRenderingOpenGL2 -- Configuring done (2.3s) CMake Error at CMakeLists.txt:136 (add_executable): Cannot find source file: main.cpp Tried extensions .c .C .c++ .cc .cpp .cxx .cu .mpp .m .M .mm .ixx .cppm .ccm .cxxm .c++m .h .hh .h++ .hm .hpp .hxx .in .txx .f .F .for .f77 .f90 .f95 .f03 .hip .ispc CMake Error at CMakeLists.txt:136 (add_executable): No SOURCES given to target: main CMake Generate step failed. Build files cannot be regenerated correctly. tao@tao:~/SLAM/ORB_SLAM3/build$ grep -i "error" cmake.log CMake Error at CMakeLists.txt:136 (add_executable): CMake Error at CMakeLists.txt:136 (add_executable): 第二步编译出来的结果
最新发布
10-27
### Git 推送时出现 `error: src refspec main does not match any` 的解决方案 当遇到 `error: src refspec main does not match any` 错误时,通常是因为本地分支名称与远程仓库的分支名称不匹配引起的。以下是详细的分析和解决方法: #### 1. **确认当前分支是否存在** 在执行推送操作之前,先检查当前所在的分支是否已经初始化并存在: ```bash git branch ``` 如果没有任何分支显示,则说明尚未创建任何分支。此时可以通过以下命令创建一个新的分支(通常是 `main` 或 `master`),并切换到该分支: ```bash git checkout -b main ``` #### 2. **验证远程仓库的默认分支名称** 许多现代 Git 托管服务(如 GitHubGitLab 等)已将默认分支从 `master` 更改为 `main`[^5]。因此,在推送前需确认目标远程仓库的实际分支名称。 通过以下命令可以查看远程仓库的信息以及其配置: ```bash git remote show origin ``` 这将返回有关远程仓库的详细信息,包括默认分支名称。 #### 3. **调整推送命令以适配实际分支名称** 假设远程仓库的默认分支为 `main`,则应使用以下命令进行推送: ```bash git push -u origin main ``` 如果远程仓库仍然使用的是旧版命名方式(即 `master`),那么需要相应更改推送命令为: ```bash git push -u origin master ``` #### 4. **处理未跟踪文件的情况** 有时此错误也可能由于工作目录中的文件未被追踪所引起。在这种情况下,可尝试添加所有文件至暂存区后再提交: ```bash git add . git commit -m "Initial commit" ``` 完成上述步骤之后再重新运行推送命令。 #### 5. **删除不必要的远程引用(如有必要)** 如果曾经设置过错误的上游分支关联关系,可能也会引发此类问题。清除现有的远程链接并通过新的指令重建连接可能会有所帮助: ```bash git remote remove origin git remote add origin https://your-repository-url.git ``` 随后再次按照正确的分支名发起推送请求。 --- ### 总结 以上提供了针对 `error: src refspec main does not match any` 这类常见问题的具体排查流程及修复措施。核心在于确保本地分支状态正常并与远端保持一致。 ```python # 示例代码片段仅用于演示如何编写脚本辅助管理分支 import os def check_git_branch(): result = os.popen(&#39;git branch&#39;).read() if &#39;main&#39; in result or &#39;master&#39; in result: print("Branch exists.") else: print("No valid branches found.") check_git_branch() ```
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值