Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,36 @@ A lint check catches unused imports, undefined names, and similar mistakes. A
formatting check keeps everyone's code looking the same so diffs show real
changes instead of whitespace. Tests are the ones you write in `tests/`.

## Sharing Repos Over the Network

One repo serves, others push and pull. Every command needs the server's
token, which is never printed back.

```bash
# in the repo that acts as the remote
minigit serve --port 9418 --token <token>

# in any other repo
minigit ls-remote 127.0.0.1:9418 --token <token> # list the remote's branches
minigit push 127.0.0.1:9418 main --token <token> # or --all for every local branch
minigit fetch 127.0.0.1:9418 main --token <token> # download history only, no ref changes
minigit pull 127.0.0.1:9418 main --token <token> # fetch, then integrate; or --all
```

- A push is rejected if the remote branch moved since you last synced
(`push rejected: ... - pull first`). Pull, merge, then push again.
- Pull fetches and validates the whole history before changing anything.
If the transfer fails, your refs, HEAD, index, and files are untouched,
and running the same pull again reuses what already arrived.
- Pulling a branch you don't have checked out creates or fast-forwards it
without touching your files. A diverged one is refused: check it out and
pull again to merge.
- Pulling into the checked-out branch fast-forwards or merges it. If both
sides changed the same lines, pull stops with the conflicting paths; fix
the conflict markers, `minigit add` the files, and `minigit commit`.
(This part needs Module 3's fetched-tip integration, #40. Until it lands,
pull refuses the checked-out branch and keeps the fetched history.)

## Docs

- [Onboarding guide](https://docs.google.com/document/d/1D77Ncmtunxj7GVADytHo1An6BKzaV-Ep7AxAYfL405k/edit?tab=t.0) -
Expand Down
12 changes: 11 additions & 1 deletion minigit/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,17 @@ def build_parser() -> argparse.ArgumentParser:

def main(argv: Sequence[str] | None = None) -> int:
parser = build_parser()
args = parser.parse_args(argv)
args, unknown = parser.parse_known_args(argv)
if unknown:
if (
getattr(args, "command", None) in {"push", "pull"}
and len(unknown) == 1
and not unknown[0].startswith("-")
and getattr(args, "branch", None) is None
):
args.branch = unknown[0]
else:
parser.error(f"unrecognized arguments: {' '.join(unknown)}")

handler = getattr(args, "handler", None)
if handler is None:
Expand Down
Loading