sync
Sync the current branch with the latest changes from the default branch.
Sync the current branch with the latest changes from the default branch.
Steps:
- Run
gh repo view --json defaultBranchRef --jq '.defaultBranchRef.name'to get the default branch name. If that fails, check which ofmainormasterexist on the remote withgit branch -r. If only one exists, use it. If both exist, ask the user which to use. If neither exists, tell the user and stop. - Run
git fetch originto get the latest remote changes. - Run
git rebase origin/<default-branch>to rebase the current branch on top of it. - If the rebase succeeds, confirm to the user that the branch is up to date.
- If the rebase hits conflicts, run
git diff --name-only --diff-filter=Uto list the conflicting files and tell the user which files need to be resolved. Do not attempt to resolve conflicts automatically.
$ARGUMENTS