gitInit.bat 979 B

12345678910111213141516171819202122232425262728293031323334
  1. @echo off
  2. setlocal enabledelayedexpansion
  3. :: 获取当前目录的完整路径
  4. set "current_dir=%CD%"
  5. :: 提取当前目录的最后一个文件夹名称(不包括路径)
  6. for %%i in ("%current_dir%") do set "folder_name=%%~nxi"
  7. :: 去除路径中的最后一个反斜杠和文件名后的点(如果有的话,比如C:\folder.)
  8. :strip_trailing_slash_and_dot
  9. if "!folder_name:~-1!"=="\" (
  10. set "folder_name=!folder_name:~0,-1!"
  11. goto :strip_trailing_slash_and_dot
  12. )
  13. if "!folder_name:~-1!"=="." (
  14. set "folder_name=!folder_name:~0,-1!"
  15. goto :strip_trailing_slash_and_dot
  16. )
  17. :: 构建你的git命令
  18. set "git_command=git remote add origin http://git.cloudpeaks.cn/droplin/%folder_name%.git"
  19. :: 输出或执行你的git命令
  20. echo !git_command!
  21. :: 如果你要实际执行这个命令,取消下面的rem注释
  22. :: !git_command!
  23. git init
  24. !git_command!
  25. endlocal
  26. pause