Namespaces

Types in GitSharp

Type Blob

Namespace GitSharp

Parent AbstractObject

Represents a specific version of the content of a file tracked by git. Using a Blob you can access the contents of any git object as string or byte array. For tracked files (leaves of a git tree) it returns the content of the file. For git objects such as Commit, Tag or Tree the Blob API may be used to inspect the the uncompressed internal representation. To open a git object instantiate a Blob with the object's Hash or another valid reference (see Ref). var b=new Blob(repo, "e287f54"); Note, that new Blob( ...) does not create a new blob in the repository but rather constructs the object to manipulate an existing blob. Advanced: To create a new Blob inside the repository you can use the static create function, however, you are advised to use higher level functionality to create new revisions of files, i.e. by using the Commit.Create API (see Commit).

Methods

Properties

Public static methods

Blob Create(Repository repo, Byte[] content)

Create a new Blob containing exactly the raw bytes given (before compression).
Parameters
Repository repo
Byte[] content

Uncompressed, encoded raw data to be stored in the blob

Blob Create(Repository repo, string content, Encoding encoding)

Create a new Blob containing the given string data as content. The string will be encoded by the submitted encoding
Parameters
Repository repo
string content

string to be stored in the blob

Encoding encoding

Blob Create(Repository repo, string content)

Create a new Blob containing the given string data as content. The string will be encoded as UTF8
Parameters
Repository repo
string content

string to be stored in the blob

Blob CreateFromFile(Repository repo, string path)

Create a new Blob containing the contents of the given file.
Parameters
Repository repo
string path

Path to the file that should be stored in the blob

Public properties

string Data get;

Get the uncompressed contents of this Blob as string. This assumes that the contents are encoded in UTF8.

string Hash get;

bool IsBlob get;

bool IsCommit get;

bool IsTag get;

bool IsTree get;

Byte[] RawData get;

Get the uncompressed original encoded raw data of the Blob as byte array. This is useful if the contents of the blob are encoded in some legacy encoding instead of UTF8.

Repository Repository get;

string ShortHash get;