git push --set-upstream <remote> <branch_name>
git branch -D <branchName>
git checkout --orphan <branchName>
git push origin --delete <branch_name>
Don’t use the prefix origin/ within <branch_name>.
git remote prune origin
git branch -u <remote>/<branch_name>
Warning! You can lose code doing this.
git reset --hard
Warning! You can lose code doing this.
git fetch origin
git reset --hard origin/<branch_name>
!!! Very destructive !!!
Relevant if you’re interested in removing sensitive data from a repository.
git push origin --force --all
git format-patch <branch_name> --stdout > ~/a-handy-patch-name.patch
git remote -v
git remote add <remote_name> <url>
Example 1 (this git-references repository):
git remote add origin git@github.com:crybx/git-references.git
Example 2 (foo.git on a Linux server):
git remote add origin ssh://<username>@<serverurl>/foo.git
git remote rm <remote_name>
git remote set-url origin <new_origin_url>