git push Command: Publish Refs in CI
git push sends local commits, branches, and tags to a remote repository.
When CI commits version bumps, changelogs, or tags, it pushes them back. The flag choices determine whether tags travel along and how safely force-pushes behave.
Common flags
--tags- push all local tags in addition to the current branch--follow-tags- push annotated tags that are reachable from the pushed commits--force-with-lease- force-push only if the remote ref has not moved since you fetched it--set-upstream/-u- set the upstream tracking ref while pushing--atomic- make the push all-or-nothing across multiple refs--delete <ref>- delete a ref on the remote
Example
shell
# Push a release commit and its annotated tag together
git push --follow-tags origin HEAD:main
# Safely update a bot branch without clobbering others' work
git push --force-with-lease origin "ci/bot-branch"In CI
Prefer --force-with-lease over --force: it refuses to overwrite work the remote received after your last fetch, preventing a stale CI runner from clobbering a teammate. Use --follow-tags so a release commit and its tag publish in one push. Authenticate with a token-bearing remote URL or credential helper.
Key takeaways
- --force-with-lease is the safe force-push: it aborts if the remote moved since your fetch.
- --follow-tags publishes a release commit and its annotated tag in a single push.
- A plain push omits tags; use --tags or --follow-tags to include them.
Related guides
git tag Command: Create Tags in CIgit tag creates and lists tags. Reference for -a annotated tags and -l listing, used to cut releases and disc…
git config Command: Configure Git in CIgit config reads and writes Git settings. Reference for user.email, --global, and credential.helper to set up…
git remote Command: Manage Remotes in CIgit remote manages the set of tracked repositories. Reference for -v and set-url, used in CI to inspect or re…
git fetch Command: Update Refs in CIgit fetch downloads objects and refs from a remote without merging. Reference for --depth, --unshallow, --tag…