git_side/commands/pull.rs
1use colored::Colorize;
2
3use crate::error::Result;
4use crate::side_repo::SideRepo;
5
6/// Pull side repo from remote.
7/// Uses fetch + reset to avoid conflicts — remote always wins.
8///
9/// # Errors
10///
11/// Returns an error if the side repo cannot be opened or pull fails.
12pub fn run() -> Result<()> {
13 let repo = SideRepo::open()?;
14 repo.ensure_initialized()?;
15
16 // Fetch from origin
17 repo.git(&["fetch", "origin"])?;
18
19 // Reset to origin/main (remote wins, no conflicts)
20 repo.git(&["reset", "--hard", "origin/main"])?;
21
22 println!("{}", "Pulled from remote.".green().bold());
23 Ok(())
24}