|
| 1 | +[](https://app.codecrafters.io/users/codecrafters-bot?r=2qF) |
| 2 | + |
| 3 | +This is a starting point for Python solutions to the |
| 4 | +["Build Your Own Git" Challenge](https://codecrafters.io/challenges/git). |
| 5 | + |
| 6 | +In this challenge, you'll build a small Git implementation that's capable of |
| 7 | +initializing a repository, creating commits and cloning a public repository. |
| 8 | +Along the way we'll learn about the `.git` directory, Git objects (blobs, |
| 9 | +commits, trees etc.), Git's transfer protocols and more. |
| 10 | + |
| 11 | +**Note**: If you're viewing this repo on GitHub, head over to |
| 12 | +[codecrafters.io](https://codecrafters.io) to try the challenge. |
| 13 | + |
| 14 | +# Passing the first stage |
| 15 | + |
| 16 | +The entry point for your Git implementation is in `app/main.py`. Study and |
| 17 | +uncomment the relevant code, and push your changes to pass the first stage: |
| 18 | + |
| 19 | +```sh |
| 20 | +git commit -am "pass 1st stage" # any msg |
| 21 | +git push origin master |
| 22 | +``` |
| 23 | + |
| 24 | +That's all! |
| 25 | + |
| 26 | +# Stage 2 & beyond |
| 27 | + |
| 28 | +Note: This section is for stages 2 and beyond. |
| 29 | + |
| 30 | +1. Ensure you have `python (3.13)` installed locally |
| 31 | +1. Run `./your_program.sh` to run your Git implementation, which is implemented |
| 32 | + in `app/main.py`. |
| 33 | +1. Commit your changes and run `git push origin master` to submit your solution |
| 34 | + to CodeCrafters. Test output will be streamed to your terminal. |
| 35 | + |
| 36 | +# Testing locally |
| 37 | + |
| 38 | +The `your_program.sh` script is expected to operate on the `.git` folder inside |
| 39 | +the current working directory. If you're running this inside the root of this |
| 40 | +repository, you might end up accidentally damaging your repository's `.git` |
| 41 | +folder. |
| 42 | + |
| 43 | +We suggest executing `your_program.sh` in a different folder when testing |
| 44 | +locally. For example: |
| 45 | + |
| 46 | +```sh |
| 47 | +mkdir -p /tmp/testing && cd /tmp/testing |
| 48 | +/path/to/your/repo/your_program.sh init |
| 49 | +``` |
| 50 | + |
| 51 | +To make this easier to type out, you could add a |
| 52 | +[shell alias](https://shapeshed.com/unix-alias/): |
| 53 | + |
| 54 | +```sh |
| 55 | +alias mygit=/path/to/your/repo/your_program.sh |
| 56 | + |
| 57 | +mkdir -p /tmp/testing && cd /tmp/testing |
| 58 | +mygit init |
| 59 | +``` |
0 commit comments