Can't get the web-site to bottom post. Sorry. Thanks Konstantin, that 4th 
web page was very helpful to me. I thought I'd see how well it works. I 
have a subdirectory which contains multiple subdirectories. Each 
subdirectory within the parent is an independent git repository. I thought 
I'd try testing out the web page to see how well I understood it. I wrote 
up a bash script to help me. And it really worked quite well. In the chance 
that it might be of interest to others, I'll post it here. It is specific 
to my subdirectory. But it should be easy to change. 

The first thing is that I couldn't "merge up". So what I did was make a new 
subdirectory (z2) which will contain the repositories contained in the 
subdirectories of the old parent (zos-backup). I called my script "" 
and put it in my HOME directory (Linux). 

cd #go to home directory
mkdir z2 #make new subdirectory
cd z2 #go to new directory
git init #init git
echo x>x #create file
git add . #add to index
git commit -m "initial commit" #and commit
cd #go back home
./ >|copy.log 2>&1  #run script shown below
diff -qr z2 zos-backup #compare to show any different files' names
cd z2
git rm x #remove that junk file
git commit -m "Merge completed"
mv zos-backup zos-backup.bkup #rename old project subdirectory
mv z2 zos-backup #rename new repository to old name
#rm -rf zos-backup.bkup #kill old repository.

Example bash script. 

set -x #show each command 
export A=/home/tsh009/zos-backup #existing directory
export B=/home/tsh009/z2 #new one
export here=$PWD #where am I?
cd $A #go to old directory
for i in *;do #for each file in old directory
        if [[ -d $i ]]; then #test that it is a directory
                cd $B #go to new directory
                ls -la #show what is there (debug)
                git remote add -f $i $A/$i 
                git merge -s ours --no-commit $i/master
                git read-tree --prefix=$i/ -u $i/master
                git commit -m "Merge directory $i"
                ls -la #so what's there now (some be same)
                cd $A #go back to old directory
cd ${here} #go back where I was.

On Wednesday, November 28, 2012 6:02:37 PM UTC-6, Konstantin Khomoutov 
> On Wed, Nov 28, 2012 at 02:13:32PM -0500, Dale R. Worley wrote: 
> > I am just beginning to use git.  I've read the O'Reilly book (by 
> > Loeliger and McCullough), and (unexpectedly) it didn't give me a clear 
> > view of some of the messier aspects of git.  So as a first question, 
> > I'd like to know if anyone knows of an exposition that gives a clear 
> > and accurate description of the logical structure of git repositories 
> > and git operations. 
> "Git from the bottom up" [1] is still relevant. 
> It's mentioned in the official documentation page [2] which contains 
> other documents of interest. 
> The manual pages for the low-level ("plumbing") commands also might shed 
> some light on the subject, but it's more hard-core reading for sure. 
> > As a second question, consider a situation I am now in.  I've been 
> > using git to maintain a repository of a directory.  I now want to 
> > start tracking all the files in the *parent* of that directory, 
> > continuing the history of all the files that are now in the 
> > repository.  I know how to use Subversion to do this, with one or two 
> > commands I can move the repository files into a subordinate directory 
> > in the repository.  But what is the correct way to do this in git? 
> As Ryan already suggested, you could go the `git mv` route. 
> Another approach is to use the `git-subtree` script which was an 
> external project for some time [3] but since some version of Git moved 
> to its "contrib" directory and is available right away. 
> With git-subtree you can create a *new* repository, add those files 
> "from the parent directory" you mentioned in your problem statement, 
> commit, and then inject your existing repository into it as a 
> subdirectory *preserving its history*. 
> The "add" command of `git-subtree` actually employs the so-called 
> "subtree merging" technique [4], whih you can also use manually as in 
> your case this will be a one-off operation. 
> It worth repeating that this route will result in a brand new repository, 
> and hence this might raise certain social problems.  Take your pick. 
> 1. 
> 2. 
> 3. 
> 4. 


Reply via email to