Push Process Guide (Non-Interactive)
Follow this guide to push code and create pull requests following Marty's workflow. All operations are command-line only — no interactive editors.
Pre-Push Checklist
Before pushing, ensure:
# 1. Verify current branch and status
git status
# 2. Check if branch exists on remote
git branch -vv
# 3. Review commits to be pushed
git log --oneline origin/main..HEAD
Push Commands
Standard Push (New Branch)
git push -u origin HEAD
Push to Update Existing Branch
git push
Push with Upstream Setting
git push --set-upstream origin feat/my-feature
Force Push
Use only when necessary — typically for:
- Amending commits that haven't been reviewed
- Rebasing your own feature branches
- Cleaning up WIP commits before PR review
git push --force-with-lease
Why --force-with-lease instead of --force:
- Refuses to push if someone else pushed to the branch
- Safer for shared branches
- Prevents accidental overwriting of others' work
When NOT to force push:
- Main/master branches
- Shared branches with active collaboration
- After PR has been approved and is pending merge
Remote Management
Check Remotes
git remote -v
Add Remote
git remote add origin https://github.com/owner/repo.git
Update Remote URL
git remote set-url origin https://github.com/owner/repo.git
Creating Pull Requests (Non-Interactive)
After pushing, create PR using gh:
# Create PR with title and body
gh pr create --title "feat(scope): description" --body "Description
Co-Authored-By: martyy-code <nesalia.inc@gmail.com>"
# Create PR from specific branch
gh pr create --base main --head feat/my-feature
# Create PR with reviewer
gh pr create --reviewer username1,username2
PR Body Template
## Summary
- What this PR does
- Why this change is needed
## Test Plan
- [ ] Test A
- [ ] Test B
## Related Issues
Closes #123
Co-Authored-By: martyy-code <nesalia.inc@gmail.com>
Handling Push Conflicts
When Push is Rejected
If push is rejected due to divergence:
# Fetch and rebase onto latest
git fetch origin && git rebase origin/main
# Or merge (if you prefer a merge commit)
git fetch origin && git merge origin/main
Resolve Conflicts
# After rebase/merge, resolve conflicts
# Edit conflicted files, then:
git add <resolved-file>
git rebase --continue
# or git merge --continue
Push Verification
After push, verify:
# Verify remote branch exists
git branch -r
# Verify commit is on remote
git log --oneline -1 origin/HEAD
# Check GitHub status (if using gh)
gh pr status
Common Mistakes to Avoid
- Force pushing main/shared branches: Never do this
- Pushing without PR for non-trivial changes: Always use branches for features/fixes
- Missing
-uon first push: Ensures tracking is set up correctly - Not verifying push: Always confirm the push succeeded
Quick Reference
Push new branch: git push -u origin HEAD
Push update: git push
Force with lease: git push --force-with-lease
Create PR: gh pr create --title "feat: description" --body "..."
Check status: git status && git branch -vv
Related Skills
| Skill | When to Use |
|---|---|
/commit |
Before push, to make proper commits |
/sync |
To sync branch with latest main |