如何在另一台计算机上克隆我的git -text-2设置的git repo ?

时间:2021-03-16 07:34:07

I have my current sublime-text-2 "Packages/User" folder in a git repo (on github)

我在git repo中有我当前的sublime-text-2“package /User”文件夹(在github上)

How do I clone it into an existing folder "Application Support/Sublime Text 2" now that I am on a new computer?

现在我在一台新电脑上,如何将它复制到现有的文件夹“应用程序支持/卓越文本2”?

Here is the repo:
http://github.com/andxyz/sublime-text-2-configs

这里是repo: http://github.com/andxyz/sublime-text-2-configs

Here is the existing folder on the new computer:

这是新计算机上现有的文件夹:

cd /Users/andxyz/Library/Application\ Support/Sublime\ Text\ 2/Packages/User

3 个解决方案

#1


5  

The following worked for me on an OSX mavericks 1.9.2 machine (after I got my github ssh clone stuff working) I did this:

以下是我在OSX mavericks 1.9.2机器上所做的工作(在我的github ssh克隆程序开始工作后):

git clone git@github.com:andxyz/sublime-text-2-configs.git ~/temp-sublime-text-2-configs
mv ~/temp-sublime-text-2-configs/.git ~/Library/Application\ Support/Sublime\ Text\ 2/.git
rm -rf ~/temp-sublime-text-2-configs
cd ~/Library/Application\ Support/Sublime\ Text\ 2/
git checkout --force master

The reasoning being that we can move the hidden .git folder from our temp-repo into the existing folder. Then move to that folder and force a git checkout with --force.

理由是,我们可以将隐藏的.git文件夹从我们的temp-repo移到现有文件夹中。然后移动到那个文件夹并强制执行一个git签出。

#2


1  

From Here: https://*.com/a/13738951/1601989

在这里:https://*.com/a/13738951/1601989

Adjusted to your question:

调整你的问题:

What you are trying to do is called a sparse checkout, and that feature was added in git 1.7.0 (Feb. 2012). The steps to do a sparse clone are as follows:

您正在尝试做的是称为稀疏校验,该特性在git 1.7.0(2012年2月)中添加。实现稀疏克隆的步骤如下:

cd /Users/andxyz/Library/Application\ Support/Sublime\ Text\ 2/
rm -rf Packages # to delete current files there
git init
git remote add -f origin http://github.com/andxyz/sublime-text-2-configs

This initiates an empty repository with your remote. Then do:

这将启动一个带有远程服务器的空存储库。然后做:

git config core.sparsecheckout true

Now you need to define which files/folders you want to actually check out. This is done by listing them in .git/info/sparse-checkout, eg:

现在需要定义要检出的文件/文件夹。这是通过在。git/info/sparse-checkout列出它们来完成的,例如:

echo "Packages" >> .git/info/sparse-checkout

Last but not least, update your empty repo with the state from the remote:

最后但并非最不重要的是,使用远程状态更新空repo:

git pull origin master

You might want to have a look at the extended tutorial and you should probably read the official documentation for sparse checkout.

您可能想看一下扩展教程,您可能应该阅读官方文档以便进行稀疏校验。

EDIT: After further pondering of why I don't really use sparse checkout anywhere I realized I use symlinks for this.

编辑:在进一步思考为什么我没有在任何地方使用稀疏校验之后,我意识到我使用符号链接。

Just clone your repository and create a symlink to the dir you want.

克隆您的存储库并创建到您想要的目录的符号链接。

#3


0  

Maybe using cURL could be an alternative? Here's a one-liner:

也许使用旋度是一种选择?这里有一个小笑话:

$ cd ~/Library/Application\ Support/Sublime\ Text\ 2/; zip -r Packages-$(date +%Y%m%d%I%M%S).zip ./Packages; rm -rf ./Packages; curl -#L https://github.com/andxyz/sublime-text-2-configs/tarball/master | tar -xzv --strip-components 1 --exclude={.gitignore,README.md}

Line-by-line breakdown:

Move to where your Packages is located:

移动到您的包所在的位置:

cd ~/Library/Application\ Support/Sublime\ Text\ 2/;

Create a backup zip of your existing Packages folder (optional):

创建现有包文件夹的备份压缩包(可选):

zip -r Packages-$(date +%Y%m%d%I%M%S).zip ./Packages;

To keep things clean, remove existing Packages folder:

为了保持整洁,删除现有的软件包文件夹:

rm -rf ./Packages;

Lastly, cURL your repo's master branch and download latest tarball; ignore boilerplate files (like README) and extract files at current location:

最后,卷起repo的主分支,下载最新的tarball;忽略样板文件(如README)并在当前位置提取文件:

curl -#L https://github.com/andxyz/sublime-text-2-configs/tarball/master | tar -xzv --strip-components 1 --exclude={.gitignore,README.md}

Bonus:

You could create a bash function to make this a simple one line bash function call.

您可以创建一个bash函数,使其成为一个简单的单行bash函数调用。

#1


5  

The following worked for me on an OSX mavericks 1.9.2 machine (after I got my github ssh clone stuff working) I did this:

以下是我在OSX mavericks 1.9.2机器上所做的工作(在我的github ssh克隆程序开始工作后):

git clone git@github.com:andxyz/sublime-text-2-configs.git ~/temp-sublime-text-2-configs
mv ~/temp-sublime-text-2-configs/.git ~/Library/Application\ Support/Sublime\ Text\ 2/.git
rm -rf ~/temp-sublime-text-2-configs
cd ~/Library/Application\ Support/Sublime\ Text\ 2/
git checkout --force master

The reasoning being that we can move the hidden .git folder from our temp-repo into the existing folder. Then move to that folder and force a git checkout with --force.

理由是,我们可以将隐藏的.git文件夹从我们的temp-repo移到现有文件夹中。然后移动到那个文件夹并强制执行一个git签出。

#2


1  

From Here: https://*.com/a/13738951/1601989

在这里:https://*.com/a/13738951/1601989

Adjusted to your question:

调整你的问题:

What you are trying to do is called a sparse checkout, and that feature was added in git 1.7.0 (Feb. 2012). The steps to do a sparse clone are as follows:

您正在尝试做的是称为稀疏校验,该特性在git 1.7.0(2012年2月)中添加。实现稀疏克隆的步骤如下:

cd /Users/andxyz/Library/Application\ Support/Sublime\ Text\ 2/
rm -rf Packages # to delete current files there
git init
git remote add -f origin http://github.com/andxyz/sublime-text-2-configs

This initiates an empty repository with your remote. Then do:

这将启动一个带有远程服务器的空存储库。然后做:

git config core.sparsecheckout true

Now you need to define which files/folders you want to actually check out. This is done by listing them in .git/info/sparse-checkout, eg:

现在需要定义要检出的文件/文件夹。这是通过在。git/info/sparse-checkout列出它们来完成的,例如:

echo "Packages" >> .git/info/sparse-checkout

Last but not least, update your empty repo with the state from the remote:

最后但并非最不重要的是,使用远程状态更新空repo:

git pull origin master

You might want to have a look at the extended tutorial and you should probably read the official documentation for sparse checkout.

您可能想看一下扩展教程,您可能应该阅读官方文档以便进行稀疏校验。

EDIT: After further pondering of why I don't really use sparse checkout anywhere I realized I use symlinks for this.

编辑:在进一步思考为什么我没有在任何地方使用稀疏校验之后,我意识到我使用符号链接。

Just clone your repository and create a symlink to the dir you want.

克隆您的存储库并创建到您想要的目录的符号链接。

#3


0  

Maybe using cURL could be an alternative? Here's a one-liner:

也许使用旋度是一种选择?这里有一个小笑话:

$ cd ~/Library/Application\ Support/Sublime\ Text\ 2/; zip -r Packages-$(date +%Y%m%d%I%M%S).zip ./Packages; rm -rf ./Packages; curl -#L https://github.com/andxyz/sublime-text-2-configs/tarball/master | tar -xzv --strip-components 1 --exclude={.gitignore,README.md}

Line-by-line breakdown:

Move to where your Packages is located:

移动到您的包所在的位置:

cd ~/Library/Application\ Support/Sublime\ Text\ 2/;

Create a backup zip of your existing Packages folder (optional):

创建现有包文件夹的备份压缩包(可选):

zip -r Packages-$(date +%Y%m%d%I%M%S).zip ./Packages;

To keep things clean, remove existing Packages folder:

为了保持整洁,删除现有的软件包文件夹:

rm -rf ./Packages;

Lastly, cURL your repo's master branch and download latest tarball; ignore boilerplate files (like README) and extract files at current location:

最后,卷起repo的主分支,下载最新的tarball;忽略样板文件(如README)并在当前位置提取文件:

curl -#L https://github.com/andxyz/sublime-text-2-configs/tarball/master | tar -xzv --strip-components 1 --exclude={.gitignore,README.md}

Bonus:

You could create a bash function to make this a simple one line bash function call.

您可以创建一个bash函数,使其成为一个简单的单行bash函数调用。