Create a git-proj Repo

Download and install git-proj.

    tUrl=https://moria.whyayh.com/rel/released/software/own/git-proj/deb
    tPkg=git-proj-0.4.1-1-mx-x86_64.deb
    tOpt="--user=guest --password=guest"
    wget $tOpt $tUrl/$tPkg

    sudo apt-get install ./$tPkg

git proj is now ready.

Get some quick usage help

Run:

    git proj

Output:

    Version: 0.5.1
    Usage:
                git proj [-v] [-V] [--version] [-h] [-H pStyle]

                git proj [pSubCmd] [pSubCmdOpt] [pComOpt]

                pSubCmd: init, remote, clone, push, pull, status
                pSubCmdOpt: Just run: "git proj [pSubCmd] -H usage"
                [common-options]: [-h] [-H pStyle] [-q -v -V N] [-x... -X N]

For even more usage help see the Documentation section at the end.

Create a "test" project

Set up a project directory with some dummy files:

    mkdir -p tmp/project/hello-world
    cd tmp/project/hello-world
    mkdir src doc
    touch src/prog1.sh doc/prog1.txt

    cd ..
    tree -aF hello-world

Output:

    hello-world/
    |-- doc/
    |   |-- prog1.txt
    |-- src/
    |   |-- prog1.sh

Create the "local" git project repo

Run git proj init in the "top" project directory:

    cd tmp/project/hello-world
    git proj init -l $PWD

Answer the 5 to 6 questions. There is quite a lot of output. This is only some of the output:

    Be sure you are "cd" to the "top" project directory,then use "-l $PWD.
    The directory name will be used for the git repo name.
    ...
    Continue [y/n]? y
    ...
    Project Path: -l /home/bruce/test/tmp/project/hello-world
    Project Name: [hello-world] Continue [y/n]? y
    ...
    Define the size for large binary files. Format: Nb, Nk, Nm, or Ng
    Press enter to accept the value shown, or type a new value.  (^c to
    quit this program.)

    Size (-s) [10k]?

    git-proj-init notice: gitproj.hook.proj-binary-file-size =
        gpMaxSize [gitproj-init.inc:170]
    git-proj-init notice: Looking for binary files are greater than
        19k: [gitproj-init.inc:210]
    git-proj-init notice: No large binary files were
        found. [gitproj-init.inc:213]

    Setup git-flow (-f) [y/n]? y
    git-proj-init notice: gitproj.config.git-flow = true [gitproj-init.inc:279]

    Summary
    ...
    Continue with creating a local git repo [y/n]? y
    ...
    Now would be a good time to setup an external drive for archiving
    your project: "git proj remote -d pMountPath"

But first, let's take a look at some of the files created or modified.

* If you did not have a ~/.gitconfig file, one was created for you.

* You should edit ~/.gitconfig and update your user name and email (these are required by git).

* If you did have a ~/.gitconfig file, it was backed up to ~/.gitconfig.bak, and the sections were added for git-flow and gitproj.

This if the project's directory tree now:

    cd tmp/project
    tree -aF hello-world/

    hello-world/
    |-- doc/
    |   |  -prog1.txt
    |-- .git/
    |   |-- branches/
    |   |-- hooks/
    |   |   |-- pre-commit*
    ...
    |   |-- info/
    |   |   |-- exclude
    |   |-- logs/
    |   |   |-- refs/
    |   |   |   |-- heads/
    |   |   |   |   |-- develop
    |   |   |   |   |-- main
    |   |   |-- HEAD
    |   |-- objects/
    |   |   |-- 16/
    |   |   |   |-- 0b28192d7c7fd93a4ffa7ff143f482f03c8cdf
    ...
    |   |   |-- info/
    |   |   |-- pack/
    |   |-- refs/
    |   |   |-- heads/
    |   |   |   |-- develop
    |   |   |   |-- main
    |   |   |-- tags/
    |   |-- COMMIT_EDITMSG
    |   |-- config
    |   |-- config.bak
    |   |-- description
    |   |-- HEAD
    |   |-- index
    |-- raw/
    |   |-- README.txt
    |-- src/
    |   |-- prog1.sh
    |-- .gitignore
    |-- .gitproj
    |-- .gitproj.bak

In the hello-world dir you have some new dirs and files. These are the interesting ones:

    hello-world/
    |-- .git/
    |   |-- branches/
    |   |-- hooks/
    |   |   |-- pre-commit*
    |   |-- config
    |raw/
    |   |-- README.txt
    |--.gitignore
    |-- .gitproj

If you look in .gitproj it will have a copy of the gitflow and getproj sections from ~/.gitconfig. (This file is versioned in git, because when the this git repo is "cloned" this file will be used to create the getproj sections in the local .git/config file.)

The raw/ directory is where you will put large binary files. If hello-world already had some large binary files then, before the git repo is created, those files would have been moved into raw/ and symlinks created to point to the files. (The symlinks are versioned.)

Between ~/.gitignore and .git/hooks/pre-commit, you will be prevented from saving large binary files in the git repo.

Try out some git commands

Now try out some git command in the project directory:

    cd tmp/project/hello-world
    git status
    git log
    touch foo.txt
    git add foo.txt
    git ci -am "Added foo.txt"
    git status -s --ignored

Try: git proj status

git proj status will give you information about differences between your local raw/ directory and the remote raw/ directory.

    git proj stats

This outputs an error and the short usage help.

     git-proj-status crit: Error: Unexpected:
         gitproj.config.remote-raw-origin should not be set to: TBD
         [gitproj-com.inc:1548](1)
     ========================================
     Usage:
         git proj status [-g "pGitOpt"] [-r "pRawOpt"] [common-options]

This is telling us a remote raw origin has not be defined. We'll do this in the next step. But first, this is a typical error log message. All error and other log messages have these parts:

    Cmd that ran: git-proj-status
       Log level: crit:
         Message: Error: Unexpected: gitproj.config.remote-raw-origin
                    should not be set to: TBD
        Location: [gitproj-com.inc:1545](1)

You can control the amount of output with config verbose variable or with the command line.

Creating a remote directory location for files in raw/

First we need to create a directory for the remote. We could mount an external disk and create the directory there. But for this tutorial we will create it under the tmp directory.

    cd tmp/project/hello-world
    cd ../..
    mkdir -p mounted-drive/repo

Creating a remote for files in raw/

Now we can run git proj remote

    cd tmp/project/hello-world
    git proj remote -d ../../mounted-drive/repo

    1) QUIT                      3) OTHER
    2) HELP                      4) ../../mounted-drive/repo
    Select by number, the location for the remote git and raw files? 4

    Use: ../../mounted-drive/repo [y/n]? y

And there is a lot more output. A lot of it can be suppressed with the -q option.

Scroll back and you can see what was done. Here are the important parts:

    git clone to ../../mounted-drive/repo
    Cloning into bare repository 'hello-world.git'

    rsync' -azC  .../tmp/project/hello-world/raw/
                 ../../mounted-drive/repo/hello-world.raw

    Running pre-commit
    [develop 755b166] git proj remote has been setup
    1 file changed, 2 insertions(+), 2 deletions(-)
    # the above a commit of a changed: .gitproj file

    # Now merge the changes to the "main" branch
    Switched to branch 'main'

    git remote origin is now: ../../mounted-drive/repo/hello-world.git
    raw remote origin is now: ../../mounted-drive/repo/hello-world.raw

Running git proj status again

    git proj status

You should see:

    On branch develop
    Your branch is up to date with 'origin/develop'.

    nothing to commit, working tree clean

    REMOTE/ = ../../mounted-drive/repo/hello-world.raw/
    No differences.

Using the raw/ directory

Let's put a file in raw/. It doesn't have to be a binary file and it can be any size. Mainly the raw/ area is just "synced" to the gitproj.config.remote-raw-origin dir

    cd tmp/project/hello-world
    echo "New file for raw" >raw/testing-raw
    echo "Another file" >raw/another-file.txt

    git proj status

Now you should see:

    REMOTE/ = ../../mounted-drive/repo/hello-world.raw/
    Only in raw/: another-file.txt
    Only in raw/: testing-raw

Pushing files to remote raw

To "save" the raw/ files to remote-raw we run git proj push (there no "commit" for files in raw/ because they are not versioned--existing files will be override.)

    git proj push

Now you'll see a "diff summary" and a "rsync dry run", showing what would be done. And the question:

    Are the above differences OK [y/n]?

If it looks OK, type 'y'

Changing files in local raw/

Now let's change a file in raw/ and remove a file, then push.

    rm raw/testing-raw
    echo "Add a line" >>raw/another-file.txt

    git proj push

Now you'll see something like:

    raw/ push
    diff summary:
    Files tmp/project/hello-world/raw/another-file.txt and ../../mounted-drive/repo/hello-world.raw/another-file.txt differ
    Only in ../../mounted-drive/repo/hello-world.raw: testing-raw

Enter 'y' to the question and do another status

    git proj status

Output:

    REMOTE/ = ../../mounted-drive/repo/hello-world.raw/
    Only in REMOTE/: testing-raw

Huh? But we deleted raw/testing-raw. Let's check help for proj push.

    git proj push -h

Oh, we need the '-d' option to allow deletes.

    git proj push -d

    git proj status

Now we see:

    REMOTE/a = ../../mounted-drive/repo/hello-world.raw/
    No differences.

When you look at the proj push help, you might have noticed this command can also run git push origin develop if you also give the -g option.

What about pulling from remote raw? First make some changes

If raw files in the remote are changed, added, or deleted, then we could do a git remote pull. Since we have direct access to the remote-raw dir we an make a manual change.

    cd ../../mounted-drive/repo/hello-world.raw/
    echo "Simulate a change" >extra-file.txt
    echo "Add another line" >>another-file.txt
    rm README.txt

Pulling from remote raw

git proj pull also has a '-d' option.

    cd tmp/project/hello-world
    git proj pull -d

Now you'll see something like:

    raw/ pull
    diff summary:
    Files ../../mounted-drive/repo/hello-world.raw/another-file.txt and
          tmp/project/hello-world/raw/another-file.txt differ
    Only in ../../mounted-drive/repo/hello-world.raw: extra-file.txt
    Only in tmp/project/hello-world/raw: README.txt

Type 'y' and do another status:

    git proj status

    REMOTE/ = ../../mounted-drive/repo/hello-world.raw/
    No differences.

Other computers have changed the remote raw files

That was a simulation of a remote-raw change. How about a typical scenario? The disk was unmounted, moved to another computer. For the other computer to access remote with git and git-proj commands, git proj clone will need to be run to setup the git workspace. Then files can be pushed and pulled from the remote raw repo area.

Set up for git proj clone simulation

We'll simulate this by cloning into another directory under the tmp dir. We'll create a place where "Bob" puts his project files.

    cd tmp/project/hello-world
    cd ../..
    mkdir -p bob/ver/proj

Run git proj clone

    cd bob/ver/proj
    git proj clone -h

    git proj clone -d ../../../mounted-drive/repo/hello-world.git

You should see something like:

    Be sure you are "cd" to the directory that the project will be cloned to.
    Clone git from: tmp/mounted-drive/repo/hello-world.git
    Clone raw from: ../../../mounted-drive/repo/hello-world.raw
    Project Name:   hello-world
    Project Dir:    tmp/bob/ver/proj/hello-world

    Continue [y/n]?

Type 'y' and you'll see another block of text describing what has been done so far.

    ...
    Summary
    ...
    Continue (commit the changes) [y/n]?

You are being asked this question because some changes could have been made to the .gitproj file that you may not want to save to the git repo. If you say 'n' here then the remote git won't be changed. For this demo, type 'y'

     tree -aF $PWD

     tmp/bob/ver/proj/
     |-- hello-world/
     |   |-- doc/
     |   |   |-- prog1.txt
     |   |-- .git/
     |   |   |-- branches/
     |   |   |-- hooks/
     |   |   |   |-- pre-commit*        # Copied from
     ...
     |   |   |-- info/
     |   |   |   |-- exclude
     |   |   |-- logs/
     |   |   |   |-- refs/
     ...
     |   |   |   |-- HEAD
     |   |   |-- objects/
     ...
     |   |   |-- refs/
     ...
     |   |   |-- COMMIT_EDITMSG
     |   |   |-- config         # Updated from PROJ/.gitproj
     |   |   |-- config.bak     # Before the update
     |   |   |-- description
     |   |   |-- HEAD
     |   |   |-- index
     |   |   |-- packed-refs
     |   |-- raw/
     |   |   |-- another-file.txt
     |   |   |-- extra-file.txt
     |   |   |-- .remote.proj   # Keep this file in raw/
     |   |-- src/
     |   |   |-- prog1.sh
     |   |-- foo.txt
     |   |-- .gitignore
     |   |-- .gitproj

Now try git proj status in bob's dir

    tmp/bob/ver/proj/hello-world
    git proj status

Output:

    On branch develop
    Your branch is up to date with 'origin/develop'.

    nothing to commit, working tree clean

    REMOTE/ = /home/bruce/test/tmp/mounted-drive/repo/hello-world.raw/
    No differences.

Documentation

Quick help:

    $ git proj

For more help, run:

    $ man git-proj

Or for help that lists all of the command with their help

    $ git proj -h

or