简体   繁体   English

创建 bat 文件,该文件将设置本地源目录并为 Git 克隆 repo

[英]Create bat file that will set local source directory and clone repo for Git

I am really new to batch file scripting, I managed to clone the repo I wanted (I think) but I am not sure how to set the save directory.我对批处理文件脚本非常陌生,我设法克隆了我想要的存储库(我认为),但我不确定如何设置保存目录。 I already saw this SO post How do I execute several git commands in a batch file without terminating after the first command?我已经看到这篇 SO 帖子如何在批处理文件中执行多个 git 命令而不在第一个命令之后终止? but I'm afraid that didn't answer my question.但恐怕这并没有回答我的问题。 Here is what I have so far:这是我到目前为止所拥有的:

pullrepo.bat: pullrepo.bat:

start "" "C:\Program Files (x86)\Git\bin\git.exe" clone git@bitbucket.org:BLAHBLAHBLAH.git
pause

When I look at the bat script (and the git window) that shows up everything seems to work, but I cannot find the folder for the local copy of the repo (by searching for folder name), much less set the local save location as I would like to.当我查看显示所有内容的 bat 脚本(和 git 窗口)时,似乎一切正常,但我找不到存储库本地副本的文件夹(通过搜索文件夹名称),更不用说将本地保存位置设置为我想要。 Eventually my goal is to also add a push function that prompts the user for a commit message inside one of the windows (git or bat)最终,我的目标是添加一个推送功能,提示用户在其中一个窗口(git 或 bat)中输入提交消息

The "save directory" is a subdirectory named after the name of the repository ( BLAHBLAHBLAH ) unless explicitly specified, in the current working directory (ie in C:\\Documents and settings\\ if I remember correctly MS Windows filesystem layout). “保存目录”是一个以存储库名称 ( BLAHBLAHBLAH ) 命名的子目录,除非明确指定,在当前工作目录中(即在 C:\\Documents and settings\\ 中,如果我没记错的话,MS Windows 文件系统布局)。 You also may specify one extra parameter to git clone and that would be the name of the cloned repo' directory.您还可以为git clone指定一个额外的参数,即克隆的 repo 目录的名称。

Also I would switch to Bash if you aren't stuck to CMD shell.如果您不坚持使用 CMD shell,我也会切换到 Bash。 Anyway Bash is supplied with Git for Windows, and it has much better and powerful scripting language to my taste.不管怎样,Bash 是随 Git for Windows 提供的,它有更好更强大的脚本语言,符合我的口味。 Also you may considr tig if you really like a console-based interactive git client :)你也可以considr tig如果你真的喜欢一个基于控制台交互git客户端:)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM