Git push

The git push command uploads your local repository content to a remote repository. This allows others to see and collaborate on your work. Once connected to a remote repository using the git remote command, you can push your changes to it.



Initial Example

To push changes from your local branch to a remote repository, use:

Tutorials dojo strip
git




PUSH Options

OptionDescription
-u, --set-upstreamSet the upstream (tracking) reference for the current branch.
-f, --forceForce the push, even if it results in a non-fast-forward update.
--allPush all local branches to the remote repository.
--tagsPush all tags to the remote repository.
--atomicEnsure that the push is atomic, meaning either all refs are updated or none are.
--dry-runPerform a trial run to show what would be pushed without making any actual changes.
--receive-pack=<git-receive-pack>Specify the git-receive-pack program to use.
--repo=<repository>Specify the remote repository to push to.
--quietSuppress all output, except for errors.
--verboseShow more information about what is being pushed.
--force-with-leaseForce the push, but only if the remote branch matches the expected commit.
--no-verifySkip pre-push, commit, and/or post-receive checks.
--push-option=<string>Pass a custom option to the remote repository.
--signed=(true|false|if-asked)Sign the push with GPG, if true, or skip signing if false.
--force-if-includesForce the push if the remote branch includes the commit being pushed.




Examples

1. Pushing to a Remote Repository

To push your local branch feature_branch to the remote repository named origin, use:

git

This command uploads your local changes to the remote repository and sets origin as the upstream for feature_branch.

2. Setting Upstream Branch

If you haven’t set up an upstream branch yet, you can do so with:

git

For example:

git

This sets origin as the upstream for feature_branch, making future pushes simpler.

3. Pushing All Branches

To push all your local branches to the remote repository, use:

git

This ensures that all your branches are updated on the remote repository.

4. Pushing Tags

To push tags to the remote repository, use:

git

This sends all your local tags to the remote repository.

5. Forcing a Push

If you need to overwrite the remote branch with your local branch, you can force the push using:

git

Be cautious when using this command, as it can overwrite changes in the remote repository.

6. Deleting a Remote Branch

To delete a branch in the remote repository, use:

git

For example, to delete a branch named feature_branch, use:

git
Tutorials dojo strip