{"id":25871008,"url":"https://github.com/forquosh/my-git","last_synced_at":"2025-03-02T06:34:20.186Z","repository":{"id":258270732,"uuid":"873573725","full_name":"Forquosh/My-Git","owner":"Forquosh","description":"My git implementation using Python.","archived":false,"fork":false,"pushed_at":"2025-02-09T00:04:01.000Z","size":23,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-09T01:19:28.015Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Forquosh.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-10-16T11:53:38.000Z","updated_at":"2025-02-09T00:04:04.000Z","dependencies_parsed_at":"2025-02-09T01:19:20.004Z","dependency_job_id":"8a49b32a-d8d1-467d-ae19-21cef63a24d1","html_url":"https://github.com/Forquosh/My-Git","commit_stats":null,"previous_names":["forquosh/my-git"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Forquosh%2FMy-Git","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Forquosh%2FMy-Git/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Forquosh%2FMy-Git/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Forquosh%2FMy-Git/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Forquosh","download_url":"https://codeload.github.com/Forquosh/My-Git/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241470357,"owners_count":19968039,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-03-02T06:34:19.285Z","updated_at":"2025-03-02T06:34:20.184Z","avatar_url":"https://github.com/Forquosh.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# My Git Implementation in Python\n\nThis project is a simple Git implementation in Python, built from scratch, to demonstrate core functionalities of Git, including **cloning a repository, writing objects, creating commits, and more**. It was written and tested throughout the **\"Build your own git\" challenge on Codecrafters**. The code supports several key Git commands and can be expanded upon for learning purposes.\n\n## Features\n\n- **Initialize a Git Repository**: Manually create the `.git` folder and initialize the necessary directory structure.\n- **Create Objects**: Store blobs, commits, and trees in a way that mirrors how Git stores data.\n- **Commit Trees**: Simulate the creation of commit objects linked to tree objects.\n- **Clone Repositories**: Clone repositories by fetching data from remote servers.\n- **Read and Decompress Git Objects**: View the contents of Git objects stored in the `.git` folder.\n\n## Supported Git Commands\n\nThe project supports the following commands (executed through the Python script):\n\n1. **`init`**: Initialize a new Git repository.\n\n```bash\n./your_program.sh init\n```\n\n2. **`hash-object -w \u003cfile\u003e`**: Write the contents of a file into the .git/objects folder as a blob.\n\n```bash\n./your_program.sh hash-object -w \u003cfile\u003e\n```\n\n3. **`write-tree`**: Write a tree object representing the current directory structure.\n\n```bash\n./your_program.sh write-tree\n```\n\n4. **`commit-tree \u003ctree_sha\u003e -p \u003ccommit_sha\u003e -m \u003cmessage\u003e`**: Create a commit object from a tree object, linking it to a parent commit and adding a message.\n\n```bash\n./your_program.sh commit-tree \u003ctree_sha\u003e -p \u003ccommit_sha\u003e -m \u003cmessage\u003e\n```\n\n5. **`clone \u003crepo_url\u003e \u003cdirectory\u003e`**: Clone a remote Git repository into a specified directory.\n\n```bash\n./your_program.sh clone \u003crepo_url\u003e \u003cdirectory\u003e\n```\n\n## How the Code Works\n\n### Cloning a Repository\n\nThe clone command initiates by creating a .git folder and fetching refs from the remote repository. After retrieving the pack file, the script processes the objects, decompressing and creating them within the cloned directory.\n\n### The steps include\n\n- Fetching refs from the remote URL.\n- Fetching the pack file containing repository objects.\n- Decompressing objects and creating corresponding tree, blob, and commit files.\n- Rendering the directory structure based on the tree object.\n- Creating and Storing Objects\n- When files are committed, they are stored as objects in the .git/objects folder using SHA-1 hashes. The create_object function handles creating these objects by compressing and writing data to the object store.\n\n**You can find the source code on my Github.**\n\n## Requirements\n\n1. Python 3.10 or higher.\n2. zlib and hashlib libraries (standard in Python).\n3. An internet connection for cloning remote repositories.\n\n## Future Improvements\n\n1. Add support for more Git commands.\n2. Optimize object handling and compression.\n3. Improve error handling and user feedback.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fforquosh%2Fmy-git","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fforquosh%2Fmy-git","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fforquosh%2Fmy-git/lists"}