Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GIT commit from memory, not file

Tags:

git

memory

Is it possible to commit an object directly from memory to a repository, or do you always have to write memory to a file, only to have git reload the file to memory?

like image 677
eswint Avatar asked May 31 '13 20:05

eswint


People also ask

How can you clean the commits from memory?

The interactive rebase tool is a great way to help you clean up Git commits and branches. When the rebase commits, a successful Git cleanup of the develop branch's commits occurs and squashes them all into one. The new Git commit created in the process is given the name E'.

How do I remove a file from a commit?

If this is your last commit and you want to completely delete the file from your local and the remote repository, you can: remove the file git rm <file> commit with amend flag: git commit --amend.

Can you commit without adding?

Without adding any files, the command git commit won't work. Git only looks to the staging area to find out what to commit. Staging, or adding, files, is possible through the command line, and also possible with most Git interfaces like GitHub Desktop by selecting the lines or files that you'd like to stage.


1 Answers

No, you don’t need to write to disk first. You can create blobs from memory, by passing the data to git hash-object -w --stdin. You can add those directly to the index or built trees with them and commit directly. Some details can be found here: http://git-scm.com/book/en/Git-Internals-Git-Objects

like image 76
Chronial Avatar answered Nov 05 '22 13:11

Chronial