Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to git clone dotfiles into my home directory with one command?

Tags:

git

bash

When you do a typical "git clone https://github.com/foo/bar.git" you get a folder in the current directory with all the files found in that directory.

What I'm looking for is an optional command line arg that lets you drop all the files from that git repo (including the .git itself) in the directory you issue the clone command from.

I'm using bash if that is a concern -thank you in advance!

like image 924
Toran Billups Avatar asked Mar 07 '13 23:03

Toran Billups


People also ask

How do I clone a git repository to a specific folder?

To clone git repository into a specific folder, you can use -C <path> parameter, e.g. Although it'll still create a whatever folder on top of it, so to clone the content of the repository into current directory, use the following syntax: cd /httpdocs git clone [email protected]:whatever .

Where do you put Dotfiles?

You need to organize your dotfiles in some directory. You could do this practically anywhere, like a USB drive or something. Since version control is great, a hosted git repository like GitHub is a great option to store your dotfiles.


2 Answers

I see what you want. You can init a git repository to your home directory then add a remote origin and pull.

cd
git init
git remote add origin https://github.com/foo/bar.git
git pull
like image 160
Damoun Avatar answered Sep 22 '22 12:09

Damoun


You are searching for the dot . ?

git clone https://github.com/foo/bar.git .

From the git clone man page:

git clone [--template=<template_directory>]
          [-l] [-s] [--no-hardlinks] [-q] [-n] [--bare] [--mirror]
          [-o <name>] [-b <name>] [-u <upload-pack>] [--reference <repository>]
          [--separate-git-dir <git dir>]
          [--depth <depth>] [--recursive|--recurse-submodules] [--] <repository>
          [<directory>]

Where (target)directory is the last argument. Note that you have to make sure that the current folder . is empty

like image 26
hek2mgl Avatar answered Sep 21 '22 12:09

hek2mgl