Create a git tree from working tree without touching the index?

I’m creating a tool that will allow people to store “solutions” to tests. Since I don’t want to reinvent version control, I decided to use git‘s tree/blob/object stuff — my idea is to create a git tree object out of the current working directory.

The problem is that I want this tool to not touch the state of the user’s repository, except to look up hashes to existing objects of course.

  • Git file is beyond a symbolic link
  • Create Git commits and push to GitHub with Ruby
  • Deploying Maven Java application to OpenShift on Tomcat 7
  • Git push over SSH on Windows won't work
  • Git GPG password in keyring
  • Guidelines for hosting VisualStudio projects on github
  • I’ve looked at both mktree and write-tree, and the former needs ls-tree output and the latter needs to examine the index. Neither of these are what I want.

    I’m happy to dive deeper and write the analogs of these commands for the working tree, however I’m having trouble figuring out any lower-level git tools to manipulate trees, blobs, and objects.

    Ideally, the user will be able to run:

    $ git create-tree .
    

    and git will spit out the hash of the newly created tree object.

  • Getting rid of '… does not point to a valid object' for an old git branch
  • Teamcity - Create git tag after successful build
  • Why does git rebase often have fewer merge conflicts than a merge?
  • Composer Package not found
  • How can I have a graphical 'diff' for git when working locally and also use diff via SSH?
  • Git pull keeps deleting everything I've added
  • One Solution collect form web for “Create a git tree from working tree without touching the index?”

    Using git mktree is certainly doable. It reads in ls-tree-formatted text, but you can generate that yourself using whatever mechanism you want.

    That said, it may be easier to go ahead and use the index. After all, you’re free to specify whatever location you want as the index, via the GIT_INDEX_FILE environment variable. Just set this var to point at some temporary location, create your index however you want, create your tree, and then reset the env var and throw away the temporary index.

    Git Baby is a git and github fan, let's start git clone.