Mat*_*att 18 linux windows git batch-file
我已经为Windows和Linux编写了脚本,基本上建立了一个新的用户工作区,其中包含来自我们服务器的所有git存储库.
我希望用户输入我们服务器的密码一次,将其存储在本地变量中,将该变量传递给每个git pull命令,然后擦除密码变量并退出.
如何在git pull命令请求时输入密码?Windows批处理文件和Linux shell脚本都有.
以下是Linux脚本中的代码:
#!/bin/bash
echo "Enter password: "
read pswd
clear #No screen peaking
#This is repeated for each repo
location=folderName
mkdir $location
cd $location
git init
git remote add origin git@<server>:$location.git
git pull origin master
#Above prompts for password & is where I want to automatically input $pswd
Run Code Online (Sandbox Code Playgroud)
我已尝试在SO和其他地方推荐的各种东西,例如管道,从.txt文件读取等.我宁愿不需要比普通的旧Windows cmd和Linux终端命令更多的东西.由于此脚本仅用于设置目的,因此我无需使用ssh代理等安全存储密码.
我正在运行Windows 7和Ubuntu 12.10,但是这个脚本用于设置新用户,因此理想情况下它适用于大多数发行版.
小智 40
概要:
git pull "https://<username>:<password>@github.com/<github_account>/<repository_name>.git" <branch_name>
Run Code Online (Sandbox Code Playgroud)
例:
git pull "https://admin:12345@github.com/Jet/myProject.git" master
Run Code Online (Sandbox Code Playgroud)
注意:这适用于bash脚本
我真的建议不要尝试管理该密码步骤,并将其(在 Linux 和 Windows 上)委托给git credential helper。
看:
用户每次会话只需输入一次密码。
| 归档时间: |
|
| 查看次数: |
37322 次 |
| 最近记录: |