Git Push
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.Example:
git push origin mastergit 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.Example:
git push origin --forcegit push <remote> --all: Push all of your local branches to the specified remote.Example:
git push origin --allgit push <remote> --tags: Push all local tags that aren't yet in the remote repositoryExample:
git push origin --tagsgit push <remote> --delete <branch-name>: Delete a specific remote branchExample:
git push origin --delete dev3Output:
To gitopia://gitopia147dgrtq5ywww473uz680fx2ucex9fv3qnw94zm/hello-world
- [deleted] dev3
You can learn more about the
git pushcommand and its options in git-scm's documentation.