Skip to content
Git

Gerenciar Remotos e Push Pull

Adicionar, alterar e interagir com repositórios remotos no Git.

#remote#push#intermediate

Code

git
# Add a remote
git remote add origin https://github.com/user/repo.git

# List remotes
git remote -v

# Change remote URL
git remote set-url origin [email protected]:user/repo.git

# Fetch from remote (no merge)
git fetch origin
git fetch --all --prune

# Pull = fetch + merge
git pull origin main
git pull --rebase origin main   # rebase instead of merge

# Push
git push origin main
git push --force-with-lease     # safer force push

# Remove a remote
git remote remove origin

# Track a remote branch
git switch -c feature origin/feature