tags:

views:

147

answers:

4

I have my dev files at ~/bin/, while my Git repo files at ~/github/myProject/. I always run the following file to copy files from the former location to the latter one:

#!/bin/zsh 

# editors# {{{
cp /Users/Masi/.emacs /Users/Masi/gitHub/MasiDvorak/
cp /Users/Masi/bin/editors/emacs/* /Users/Masi/gitHub/MasiDvorak/editors/emacs/

cp /Users/Masi/.vimrc /Users/Masi/gitHub/MasiDvorak/
cp /Users/Masi/bin/editors/vim/* /Users/Masi/gitHub/MasiDvorak/editors/vim/
# }}}
# shells# {{{
cp /Users/Masi/.bashrc /Users/Masi/gitHub/MasiDvorak/
cp /Users/Masi/.profile /Users/Masi/gitHub/MasiDvorak/
cp /Users/Masi/.zshrc /Users/Masi/gitHub/MasiDvorak/
# }}}

# programming# {{{
cp /Users/Masi/.screenrc /Users/Masi/gitHub/MasiDvorak/
cp /Users/Masi/.Xmodmap /Users/Masi/gitHub/MasiDvorak/
cp /Users/Masi/.xmonad/xmonad.hs /Users/Masi/gitHub/MasiDvorak/.xmonad/
cp /Users/Masi/.gdbinit /Users/Masi/gitHub/MasiDvorak/ 
cp /Users/Masi/.xmonad/xmonad.hs /Users/Masi/gitHub/MasiDvorak/ 
...
# }}}

The reason is that I want to avoid the files such as

xmonad.hs~   # all ~ -files
.gitconfig

to be added to my Git repo.

My way of coping the files starts to be challenging to be controlled, since it is time-consuming for me to find and add each file to the file copy_dev-files_to_github.

How do you copy development files to your local Git repo?

+1  A: 

You could use rsync with the --exclude option.

e.g.

rsync --exclude='.gitconfig' --exclude='*~' /Users/Masi/ /Users/Masi/gitHub/MasiDvorak/
Jeremy Smyth
@Jeremy: I run your command with the addition of % --exclude=*.a %. I get % ./toCopyDotFiles:3: no matches found: --exclude=*.a %. How can you avoid the warning?
Masi
Not sure - it might be something else on that line. Another option for you to try is the --exclude-from=FILE option, where you specify a filename containing a list of exclude options. That'll clean up the commandline :)
Jeremy Smyth
@Jeremy: I run only your code. I get the following: ./toCopyDotFiles:3: no matches found: --exclude=*~ % This suggests me that something is wrong in the exclude command.
Masi
I've edited it slightly - try that?
Jeremy Smyth
+3  A: 

Why are you manually copying files around at all? Surely you should just add them to the repo, then check out and commit as necessary. I don't see the need to move the files around - that seems to defeat the whole purpose of a local checkout.

To avoid adding certain files, just list them in .git/info/exclude.

Daniel Roseman
I put *.[ao], *~ and .gitconfig to the file. I created a new file by % touch masi~ *. I run % git add .% The file masi~ was added to my repo. --- This suggests me that I have not understood the purpose of the exclude -file correctly.
Masi
Your command should work. I read the following docs and still the same problem persists: http://ftp.kernel.org/pub/software/scm/git/docs/v1.0.13/git-ls-files.html
Masi
@Daniel: A new thread started based on your answer at the thread http://stackoverflow.com/questions/1053867/unable-to-work-effectively-with-git-locally
Masi
+1  A: 

Once a file is added to the repository, excluding will not make git ignore that file.
try using a .gitignore file on a fresh repository. also you should probably play around in a noncritical directory, rather than your home directory.

Naveen
+1  A: 

Another solution might be to change the infra structure of your development enviroment, so that these copying steps aren't needed in the first place.

Magnus Skog
@Magnus: Your point is excellent! --- I will make a repo for my dotFiles at HOME and one repo for my other dotFiles at ~/bin. In short, to divide one repo to two.
Masi