A collection of helpful git commands when working in a team of developers
To check your repository's remote URL:
git config --get remote.origin.url
Renaming a separate branch:
git branch -m <old_name> <new_name>
Renaming current branch:
git branch -m <new_name>
Pushing changes to remote:
git push -u origin <new_name>
git push origin :<old_name>
Delete a branch locally:
git branch -d live-branch/branch-name
Force a branch delete:
git branch D live-branch/branch-name
Delete a remote branch:
git push remote :live-branch/branch-name
Fetch latest and remove obsolete tracking changes:
git fetch --all --prune
View both local and remote branches:
git branch -a
View all of your remote branches only:
git branch -r
View full output of fetch url, push url, HEAD branch, tracked remote branches, local branches configured for git pull and refs configured for git push
git show remote origin
Updating and rebasing from master:
git pull origin master --rebase
Pushing rebased branch with lease:
git push --force-with-lease