Push command in Git

The git push command is used to upload local repository content to a remote repository. It is most commonly used to publish and 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.

svg viewer

Syntax

This command’s syntax is as follows:

git push <repo name> <branch name>

Pushing to all branches in a specific repository

If you want to push all your changes (in all the branches) to a remote repository, you can use:

git push --all <REMOTE-NAME>

The --all flag tells the system that all branches need to be pushed to the remote repository. You will want to push the branches to the <REMOTE-NAME>.

Pushing with --force flag

The --force flag tells Git to ignore the local changes made to the Git repository at Github.

git push <remote> --force

Copyright ©2024 Educative, Inc. All rights reserved