Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I'm learning git, and the test case I'm using it for is keeping a repo of my linux profile settings (.bashrc .profile .tmux.conf etc)

on my main machine, the repo is created at the home folder: base=/home/bvector/ files=/home/bvector/.profile, etc

but when I go to clone the repo on machine2, it goes to /home/bvector/home (as the repo is called home) base=/home/bvector/home/ files=/home/bvector/home/.profile, etc

Is there a way to have the cloned repo be based in my home folder with all the files in the correct place by default? Everything I've read says you cant clone a repo to a nonempty directory, which would make it a lot more cumbersome to have the repo on multiple machines and be able to seamlessly commit changes.

share|improve this question

3 Answers 3

up vote 3 down vote accepted

Github has just launched a set of new pages describing how to use Github for this scenario.

http://dotfiles.github.com/

share|improve this answer
    
this is an amazing resource, and it is so useful I'm going to select it as the answer, even though my answer solved my problem, this is probably the best way to do it –  bVector Apr 25 '12 at 1:02

An easy (inelegant?) thing to do would be:

git clone --bare whatever ~/.git

The --bare option tells it to basically checkout the contents of a normal .git directory (so it won't check out a working copy), and put into the directory ~/.git. You can use git checkout <file> to get individual files, or git reset --hard to replace all your existing files with their equivalent in your git repository, if they exist.

share|improve this answer
cd ~
git init
git remote add origin ssh://host/repo.git
git pull origin master

this works for this situation. from http://stackoverflow.com/questions/9443927/git-clone-into-home-directory

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.