git push is the git command used to upload the contents of a local repository to the corresponding remote repository. git push updates the remote branch with local commits. It is one of the four commands in Git that prompts interaction with the remote repository. Pushing is capable of overwriting changes; caution should be taken when pushing.
git push is most commonly used to publish an upload local changes to a central repository. After a local repository has been modified a push is executed to share the modifications with remote team members.
Git Push Syntax:
git push <option> [<Remote URL><branch name><refspec>...]
Git Push Common Usage
git push <remote> <branch>: Push the specified branch, along with all of the necessary commits and internal objects. This creates a local branch in the destination repository. To prevent you from overwriting commits, Git won’t let you push when it results in a non-fast-forward merge in the destination repository.
git push origin master
git push <remote> --force: Force a push that would otherwise be blocked, usually because it will delete or overwrite existing commits. Do not use the
--forceflag unless you’re absolutely sure you know what you’re doing.
git push origin --force
git push <remote> --all: Push all of your local branches to the specified remote.
git push origin --all
git push <remote> --tags: Push all local tags that aren't yet in the remote repository
git push origin --tags
git push <remote> --delete <branch-name>: Delete a specific remote branch
git push origin --delete dev3
- [deleted] dev3
You can learn more about the
git pushcommand and its options in git-scm's documentation.