Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6198157
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T03:56:53+00:00 2026-05-24T03:56:53+00:00

I have a small application that manages several git repositories similar to Github/Gitorious. Github

  • 0

I have a small application that manages several git repositories similar to Github/Gitorious. Github allows for inline file editing, and I’d like to know if anyone has any idea on how they manage this.

My initial thought was that it would do a complete clone of the repository, use your submission to replace the file, commit, and push, but this seems like an very expensive operation with large repositories like the linux kernel.

Any ideas on a more efficient way to add and edit files to a bare repository?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T03:56:53+00:00Added an answer on May 24, 2026 at 3:56 am

    You can use plumbing commands.

    Get your current HEAD, get the tree from there then your blobs.

    Once you have the blob you can put the content in a textbox. When it’s finished you just have to hash the new blob, create the new tree, the new commit and tadaam. It’s “pushed”.

    PS: Remember you’re in a bare repository, so check that every command you use don’t need the index nor the working directory.


    As it has been asked here is a step by step example.

    First we get the current file content:

    > git cat-file -p HEAD:var/test/text.txt
    test
    

    We do our little modification on that content and now have a new content ready to be pushed.
    To save that content we’re going to hash it:

    > git hash-object -t blob -w var/test/text.txt
    9764d221e6b50063b83c0268544c5d5b745ec9c5
    

    This will save it, and return a sha-1 of that object (blob), the very next step consist in creating a new folder test which will contain our text.txt file. But first let’s look at what does the current test folder look like:

    > git ls-tree HEAD:var/test
    100644 blob 9daeafb9864cf43055ae93beb0afd6c7d144bfa4    text.txt
    

    So what we want to do here, is replace the previous SHA-1 (9daeafb...) with the new one (9764d22...) and generate a new tree based on that (pay attention to the \t).

    > echo -e "100644 blob 9764d221e6b50063b83c0268544c5d5b745ec9c5\ttext.txt" | git mktree
    b7788f9e8e9a24be31188167a6a0bc1de9e41d24
    

    Great, so now we have the new file text.txt and the parent folder test, we now need var.

    > git ls-tree HEAD:var
    040000 tree 9bfb857f532d280ecd7704beb40a2ea4ba332f5a    test
    
    > echo -e "040000 tree b7788f9e8e9a24be31188167a6a0bc1de9e41d24\ttest" | git mktree
    536f33626a47138499fade7df6d02327f75d80be
    

    and now we need the parent of var (which is the root of our repository):

    > git ls-tree HEAD
    040000 tree 31a6ee5e7d14a0569721632a05234185a109d6bd    var
    
    > echo -e "040000 tree 536f33626a47138499fade7df6d02327f75d80be\tvar" | git mktree
    7db3d6bc14cce98ff89ccc285b9d17965f5ca92b
    

    And it’s done, our tree is ready. The only thing missing is the actual commit:

    > git commit-tree -p HEAD -m "commit message" 7db3d6bc14cce98ff89ccc285b9d17965f5ca92b
    4aa2de2cf9e3e4f5470bcd1ee1e83ef6e4025eaf
    

    But it isn’t ready yet, now we want the commit to be the HEAD, so the very last step is:

    > git update-ref HEAD 4aa2de2cf9e3e4f5470bcd1ee1e83ef6e4025eaf
    

    And now we’re done.


    Resources:

    • git hash-object
    • git cat-file
    • git ls-tree
    • git mk-tree
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a small web application based on asp.net 2010 that manages invoices. After
I have a small application that I am building a Chat application into, so
I have a small application that uses a SharePoint list as the data source.
I have a small application that redirects the stdout/in of an another app (usually
I have a small lightweight application that is used as part of a larger
I have a small application which embeds webbrowser controls. In that application I have
I have a small VB.NET application that I'm working on using the full version
I have a small application I am working on that at one point needs
I have a small AJAX application, written in PHP that I did not secure
I have a small command-line application written in C that acts as a wrapper/launcher

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.