执行git sparse checkout时转义目录名称中的空间 [英] Escaping space in directory name while doing git sparse checkout

查看:101
本文介绍了执行git sparse checkout时转义目录名称中的空间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尝试在jenkins中使用git sparse结帐.但是,这件事似乎并不喜欢我尝试使用的方式来获取名称中带有空格的子目录.

Trying to use the git sparse checkout in jenkins. But this thing doesn't seem to like the ways which i am trying use to get a sub-directory with space in the name.

例如我正在尝试获取文件夹:

E.g. i am trying to get the folder:

/foo/bar baz/folder/desired_folder

我已经尝试过运气了,

"/foo/bar baz/folder/desired_folder"
/foo/bar\ baz/folder/desired_folder

使用git bash验证稀疏签出时会看到相同的性质. 有没有办法逃脱空间.否则我必须重命名文件夹并再次签入

The same nature is seen while using the git bash to verify the sparse checkout. Is there a way to escape the space. Else i have to rename the folders and checkin again

推荐答案

我刚刚遇到了这个问题,这是在git version 2.10.2.windows.1中对我有用的东西.

I just encountered this issue and here's what worked for me, in git version 2.10.2.windows.1.

我为此示例创建的测试存储库: https://github.com/dixon/TestSparseCheckout

Test repo that I created for this example: https://github.com/dixon/TestSparseCheckout

遵循这些出色的说明,这是我使用的echo命令-我没有逃脱任何操作,但我添加了*:

Following these excellent instructions, here's the echo command I used - I didn't escape anything, but I added an *:

$ echo "Folder With Spaces/*" >> .git/info/sparse-checkout

$ cat .git/info/sparse-checkout
Folder With Spaces/*

然后进行验证:

$ git pull origin master
From https://github.com/dixon/TestSparseCheckout
 * branch            master     -> FETCH_HEAD

$ ls
total 8.0K
drwxr-xr-x 1 dixon 0 Mar 21 14:21 ./
drwxr-xr-x 1 dixon 0 Mar 21 14:19 ../
drwxr-xr-x 1 dixon 0 Mar 21 14:21 .git/
drwxr-xr-x 1 dixon 0 Mar 21 14:21 'Folder With Spaces'/

$ ls Folder\ With\ Spaces/
total 1.0K
drwxr-xr-x 1 dixon  0 Mar 21 14:21 ./
drwxr-xr-x 1 dixon  0 Mar 21 14:21 ../
-rw-r--r-- 1 dixon 10 Mar 21 14:21 'Should Checkout.txt'

看起来很有效;没有下载 DoNotCheckout .

Looks like it worked; the DoNotCheckout wasn't downloaded.

这篇关于执行git sparse checkout时转义目录名称中的空间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆