Remote Repository Management
Understanding Remote Repositories
Remote Repository Types
Repository Type |
Platform |
Characteristics |
GitHub |
Microsoft |
Most popular |
GitLab |
GitLab Inc. |
Self-hostable |
Bitbucket |
Atlassian |
Enterprise focus |
Connecting to Remote Repositories
Adding Remote Repository
## Add remote repository
## View current remotes
Remote Workflow
graph TD
A[Local Repository] -->|Push| B[Remote Repository]
B -->|Pull| A
B -->|Clone| C[Another Local Repository]
Essential Remote Commands
Pushing Changes
## Push to main branch
git push origin main
## Push all branches
git push --all origin
Pulling Changes
## Fetch remote changes
git fetch origin
## Pull and merge
git pull origin main
Authentication Methods
SSH Key Setup
## Generate SSH key
ssh-keygen -t rsa -b 4096 -C "[email protected]"
## Copy SSH public key
cat ~/.ssh/id_rsa.pub
Personal Access Tokens
## Generate token in repository platform settings
## Use token for HTTPS authentication
Branch Management
## Create new branch
git branch feature-branch
## Switch to branch
git checkout feature-branch
## Push branch to remote
git push -u origin feature-branch
Collaborative Workflows
Pull Request Process
graph LR
A[Create Branch] --> B[Make Changes]
B --> C[Push to Remote]
C --> D[Open Pull Request]
D --> E[Code Review]
E --> F[Merge to Main]
Resolving Conflicts
## Fetch latest changes
git fetch origin
## Merge and resolve conflicts
git merge origin/main
LabEx Tip
LabEx offers comprehensive remote repository management tutorials and interactive environments for practical learning.
Best Practices
- Always pull before pushing
- Use meaningful branch names
- Communicate with team members
- Review code before merging
- Keep repositories organized