From 7c0011c55a0bf2477416e33c3df73ad4125852b5 Mon Sep 17 00:00:00 2001 From: Oliver Davies Date: Wed, 6 Mar 2019 19:50:29 +0000 Subject: [PATCH] wip --- ...r-git-repository-cloning-with-insteadof.md | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 source/_posts/easier-git-repository-cloning-with-insteadof.md diff --git a/source/_posts/easier-git-repository-cloning-with-insteadof.md b/source/_posts/easier-git-repository-cloning-with-insteadof.md new file mode 100644 index 00000000..b6da99ca --- /dev/null +++ b/source/_posts/easier-git-repository-cloning-with-insteadof.md @@ -0,0 +1,29 @@ +--- +title: Easier Git Repository Cloning with inteadof +date: 2019-02-06 +tags: [] +draft: true +--- +## What is insteadOf? + +From the [Git documentation](https://git-scm.com/docs/git-config#git-config-urlltbasegtinsteadOf): + +{% raw %}
+Any URL that starts with this value will be rewritten to start, instead, with . In cases where some site serves a large number of repositories, and serves them with multiple access methods, and some users need to use different access methods, this feature allows people to specify any of the equivalent URLs and have Git automatically rewrite the URL to the best alternative for the particular user, even for a never-before-seen repository on the site. When more than one insteadOf strings match a given URL, the longest match is used. +
{% endraw %} + +## Example + +For example to clone a Drupal module from Drupal.org, I can add this snippet to my `~/.gitconfig` file: + +``` +[url "https://git.drupal.org/project/"] + insteadOf = do: + insteadOf = drupal: +``` + +This means that I can now do `git clone drupal:` or `git clone do:` to clone the repository, specifying the project’s machine name. + +For example, to clone the Override Node Options module, I can now do this using `git clone drupal:override_node_options`. + +You can view my entire `~/.gitconfig` file and my other dotfiles in [my dotfiles repository on GitHub](https://github.com/opdavies/dotfiles/blob/master/.gitconfig).