Frage

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

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

Here is the 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
War es hilfreich?

Lösung

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:

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.

Andere Tipps

From Here: https://stackoverflow.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:

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:

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

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

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.

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:

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.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top