LinuxCommandLibrary

git-push

Upload local commits to remote

TLDR

Push to remote

$ git push [origin] [branch]
copy
Push and set upstream
$ git push -u [origin] [branch]
copy
Push all branches
$ git push --all
copy
Push tags
$ git push --tags
copy
Force push
$ git push --force-with-lease
copy

SYNOPSIS

git push [options] [remote] [refspec]

DESCRIPTION

git push uploads local commits to a remote repository, updating remote refs with local refs and transferring the objects needed to complete them. This is how local work becomes shared with collaborators.
The `--force-with-lease` option provides a safer alternative to `--force` by checking that the remote hasn't been updated since your last fetch before overwriting. The `-u` flag sets upstream tracking, simplifying future push and pull commands.

PARAMETERS

REMOTE

Remote repository name.
REFSPEC
Refs to push.
-u, --set-upstream
Set upstream tracking.
--all
Push all branches.
--tags
Push tags.
--force
Force update remote refs.
--force-with-lease
Safe force push.
--delete
Delete remote ref.
--dry-run
Show what would be pushed.
--help
Display help information.

CAVEATS

Force push overwrites remote history. Use --force-with-lease for safety. Branch protection may restrict pushes.

HISTORY

git push is a core Git command from initial release, implementing the distributed workflow by enabling commit sharing.

SEE ALSO

> TERMINAL_GEAR

Curated for the Linux community

Copied to clipboard

> TERMINAL_GEAR

Curated for the Linux community