Git Multiple Computer Workflow
Git Multi-Computer Workflow Guide
Daily Workflow Between Computers
Starting Work (Always do this first)
git pull
Finishing Work (Always do this when done)
git add .
git commit -m "Your commit message"
git push
Setting Up a New Computer with Existing Repository
1. Initial Setup
git clone https://github.com/username/repository.git
cd repository
2. Get Remote Branch that Exists on Other Computer
git fetch origin
git checkout branch-name
3. Clean Up Old/Deleted Branches
git remote prune origin
Handling Branch Creation and Deletion
Creating a New Branch (Computer A)
git checkout -b new-branch-name
# Make your changes
git add .
git commit -m "Initial work on new branch"
git push -u origin new-branch-name
Getting New Branch on Other Computer (Computer B)
git fetch origin
git checkout new-branch-name
Deleting a Branch (Computer A)
git checkout main
git branch -d branch-name # Delete locally
git push origin --delete branch-name # Delete on remote
Cleaning Up Deleted Branch on Other Computer (Computer B)
git checkout main
git branch -d branch-name # Delete local copy
git remote prune origin # Remove stale references
Common Issues and Solutions
“Non-fast-forward” Error When Pushing
git pull origin branch-name --no-rebase
git push
Divergent Branches Message
git config pull.rebase false
git pull origin branch-name
File Changes After Flutter/SDK Installation
- DO commit and push
pubspec.lock
changes - These ensure dependency consistency across computers
git add pubspec.lock git commit -m "Update pubspec.lock after Flutter installation" git push
Useful Commands for Multi-Computer Work
See All Branches (Local and Remote)
git branch -a
See Only Remote Branches
git branch -r
Check What Exists on Remote Right Now
git ls-remote origin
See Status of Local vs Remote
git status
Key Principles
- Always pull before starting work
- Always push when finishing work
- Commit
pubspec.lock
and similar dependency files - Use
git remote prune origin
to clean up deleted branches - Use
git fetch origin
to discover new branches
Remember
git fetch origin
downloads branch info but doesn’t create local branchesgit checkout branch-name
creates the local branch and switches to it- Remote-tracking branches (
remotes/origin/branch-name
) are read-only references - Local branches are where you actually do work and make commits