neulab/tldr huggingface dataset:
--uninstall PKG,PKG.. (see "customize" below) Uninstall the named packages (a comma-separated list).  These are removed during the image build using the guest’s package manager (eg. apt, yum, etc.).  Dependent packages may also need to be uninstalled to satisfy the request.
See also --install, --update.
--update (see "customize" below) Do the equivalent of "yum update", "apt-get upgrade", or whatever command is required to update the packages already installed in the template to their latest versions.
See also --install, --uninstall.
--upload FILE:DEST (see "customize" below) Upload local file "FILE" to destination "DEST" in the disk image. File owner and permissions from the original are preserved, so you should set them to what you want them to be in the disk image.
"DEST" could be the final filename.  This can be used to rename the file on upload.
If "DEST" is a directory name (which must already exist in the guest) then the file is uploaded into that directory, and it keeps the same name as on the local filesystem.
See also: --mkdir, --delete, --scrub.
--write FILE:CONTENT (see "customize" below) Write "CONTENT" to "FILE".
If the --enable/--operations option is not given, then most sysprep operations are enabled.
Use "virt-sysprep --list-operations" to list all operations for your virt-sysprep binary.  The ones which are enabled by default are marked with a "*" character.  Regardless of the --enable/--operations options, sysprep operations are skipped for some guest types.
Operations can be individually enabled using the --enable/--operations options.  Use a comma-separated list, for example:
virt-sysprep --operations ssh-hostkeys,udev-persistent-net [etc..]
Future versions of virt-sysprep may add more operations.  If you are using virt-sysprep and want predictable behaviour, specify only the operations that you want to have enabled.
"*" = enabled by default when no --enable/--operations option is given.
abrt-data * Remove the crash data generated by ABRT.
Remove the automatically generated ABRT crash data in "/var/spool/abrt/".
backup-files * Remove editor backup files from the guest.
The following files are removed from anywhere in the guest filesystem:
·   *.bak
·   *~
On Linux and Unix operating systems, only the following filesystems will be examined:
·   /etc
·   /root
·   /srv
·   /tmp
·   /var
bash-history * Remove the bash history in the guest.
Remove the bash history of user "root" and any other users who have a ".bash_history" file in their home directory.
Notes on bash-history
Currently this only looks in "/root" and "/home/*" for home directories, so users with home directories in other locations won't have the bash history removed.
blkid-tab * Remove blkid tab in the guest.
ca-certificates Remove CA certificates in the guest.
In case any certificate is removed, the system CA store is updated.
crash-data * Remove the crash data generated by kexec-tools.
Remove the automatically generated kdump kernel crash data.
cron-spool * Remove user at-jobs and cron-jobs.
customize * Customize the guest.
Customize the guest by providing virt-customize(1) options for installing packages, editing files and so on.
dhcp-client-state * Remove DHCP client leases.
dhcp-server-state * Remove DHCP server leases.
dovecot-data * Remove Dovecot (mail server) data.
firewall-rules Remove the firewall rules.
This removes custom firewall rules by removing "/etc/sysconfig/iptables" or custom firewalld configuration in "/etc/firewalld/*/*".
Note this is not enabled by default since it may expose guests to exploits.  Use with care.
flag-reconfiguration Flag the system for reconfiguration.
For Linux guests, this touches "/.unconfigured", which causes the first boot to interactively query the user for settings such as the root password and timezone.
fs-uuids Change filesystem UUIDs.
On guests and filesystem types where this is supported, new random UUIDs are generated and assigned to filesystems.
Notes on fs-uuids
The fs-uuids operation is disabled by default because it does not yet find and update all the places in the guest that use the UUIDs.  For example "/etc/fstab" or the bootloader.  Enabling this operation is more likely than not to make your guest unbootable.
See: https://bugzilla.redhat.com/show_bug.cgi?id=991641
ipa-client * Remove the IPA files.
Remove all the files related to an IPA (Identity, Policy, Audit) system. This effectively unenrolls the guest from an IPA server without interacting with it.
This operation does not run "ipa-client".
kerberos-data Remove Kerberos data in the guest.
kerberos-hostkeytab * Remove the Kerberos host keytab file in the guest.
logfiles * Remove many log files from the guest.
On Linux the following files are removed:
·   /etc/Pegasus/*.cnf
·   /etc/Pegasus/*.crt
·   /etc/Pegasus/*.csr
·   /etc/Pegasus/*.pem
·   /etc/Pegasus/*.srl
·   /root/anaconda-ks.cfg
·   /root/anaconda-post.log
·   /root/initial-setup-ks.cfg
·   /root/install.log
·   /root/install.log.syslog
·   /root/original-ks.cfg
·   /var/cache/fontconfig/*
·   /var/cache/gdm/*
·   /var/cache/man/*
·   /var/lib/AccountService/users/*
·   /var/lib/fprint/*
·   /var/lib/logrotate.status
·   /var/log/*.log*
·   /var/log/BackupPC/LOG
·   /var/log/ConsoleKit/*
·   /var/log/anaconda.syslog
·   /var/log/anaconda/*
·   /var/log/apache2/*_log
·   /var/log/apache2/*_log-*
·   /var/log/apt/*
·   /var/log/aptitude*
·   /var/log/audit/*
·   /var/log/btmp*
·   /var/log/ceph/*.log
·   /var/log/chrony/*.log
·   /var/log/cron*
·   /var/log/cups/*_log*
·   /var/log/debug*
·   /var/log/dmesg*
·   /var/log/exim4/*
·   /var/log/faillog*
·   /var/log/firewalld*
·   /var/log/gdm/*
·   /var/log/glusterfs/*glusterd.vol.log
·   /var/log/glusterfs/glusterfs.log
·   /var/log/grubby*
·   /var/log/httpd/*log
·   /var/log/installer/*
·   /var/log/jetty/jetty-console.log
·   /var/log/journal/*
·   /var/log/lastlog*
·   /var/log/libvirt/libvirtd.log
·   /var/log/libvirt/libxl/*.log
·   /var/log/libvirt/lxc/*.log
·   /var/log/libvirt/qemu/*.log
·   /var/log/libvirt/uml/*.log
·   /var/log/lightdm/*
·   /var/log/mail/*
·   /var/log/maillog*
·   /var/log/messages*
·   /var/log/ntp
·   /var/log/ntpstats/*
·   /var/log/ppp/connect-errors
·   /var/log/rhsm/*
·   /var/log/sa/*
·   /var/log/secure*
·   /var/log/setroubleshoot/*.log
·   /var/log/spooler*
·   /var/log/squid/*.log
·   /var/log/syslog*
·   /var/log/tallylog*
·   /var/log/tuned/tuned.log
·   /var/log/wtmp*
·   /var/log/xferlog*
·   /var/named/data/named.run
lvm-uuids * Change LVM2 PV and VG UUIDs.
On Linux guests that have LVM2 physical volumes (PVs) or volume groups (VGs), new random UUIDs are generated and assigned to those PVs and VGs.
machine-id * Remove the local machine ID.
The machine ID is usually generated from a random source during system installation and stays constant for all subsequent boots.  Optionally, for stateless systems it is generated during runtime at boot if it is found to be empty.
mail-spool * Remove email from the local mail spool directory.
net-hostname * Remove HOSTNAME and DHCP_HOSTNAME in network interface configuration.
For Fedora and Red Hat Enterprise Linux, this is removed from "ifcfg-*" files.
net-hwaddr * Remove HWADDR (hard-coded MAC address) configuration.
pacct-log * Remove the process accounting log files.
The system wide process accounting will store to the pacct log files if the process accounting is on.
package-manager-cache * Remove package manager cache.
pam-data * Remove the PAM data in the guest.
passwd-backups * Remove /etc/passwd- and similar backup files.
·   /etc/group-
·   /etc/gshadow-
·   /etc/passwd-
·   /etc/shadow-
·   /etc/subgid-
·   /etc/subuid-
puppet-data-log * Remove the data and log files of puppet.
rh-subscription-manager * Remove the RH subscription manager files.
rhn-systemid * Remove the RHN system ID.
rpm-db * Remove host-specific RPM database files.
Remove host-specific RPM database files and locks.  RPM will recreate these files automatically if needed.
samba-db-log * Remove the database and log files of Samba.
script * Run arbitrary scripts against the guest.
The "script" module lets you run arbitrary shell scripts or programs against the guest.
Note this feature requires FUSE support.  You may have to enable this in your host, for example by adding the current user to the "fuse" group, or by loading a kernel module.
Use one or more --script parameters to specify scripts or programs that will be run against the guest.
The script or program is run with its current directory being the guest’s root directory, so relative paths should be used.  For example: "rm etc/resolv.conf" in the script would remove a Linux guest’s DNS configuration file, but "rm /etc/resolv.conf" would (try to) remove the host’s file.
Normally a temporary mount point for the guest is used, but you can choose a specific one by using the --scriptdir parameter.
Note: This is different from --firstboot scripts (which run in the context of the guest when it is booting first time).  --script scripts run on the host, not in the guest.
smolt-uuid * Remove the Smolt hardware UUID.
ssh-hostkeys * Remove the SSH host keys in the guest.
The SSH host keys are regenerated (differently) next time the guest is booted.
If, after cloning, the guest gets the same IP address, ssh will give you a stark warning about the host key changing:
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @    WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!     @ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
ssh-userdir * Remove ".ssh" directories in the guest.
Remove the ".ssh" directory of user "root" and any other users who have a ".ssh" directory in their home directory.
Notes on ssh-userdir
Currently this only looks in "/root" and "/home/*" for home directories, so users with home directories in other locations won't have the ssh files removed.
sssd-db-log * Remove the database and log files of sssd.
tmp-files * Remove temporary files.
This removes temporary files under "/tmp" and "/var/tmp".
udev-persistent-net * Remove udev persistent net rules.
Remove udev persistent net rules which map the guest’s existing MAC address to a fixed ethernet device (eg. eth0).
After a guest is cloned, the MAC address usually changes.  Since the old MAC address occupies the old name (eg. eth0), this means the fresh MAC address is assigned to a new name (eg. eth1) and this is usually undesirable.  Erasing the udev persistent net rules avoids this.
user-account Remove the user accounts in the guest.
By default remove all the user accounts and their home directories.  The "root" account is not removed.
See the --remove-user-accounts parameter for a way to specify how to remove only some users, or to not remove some others.
utmp * Remove the utmp file.
This file records who is currently logged in on a machine.  In modern Linux distros it is stored in a ramdisk and hence not part of the virtual machine’s disk, but it was stored on disk in older distros.
yum-uuid * Remove the yum UUID.
Yum creates a fresh UUID the next time it runs when it notices that the original UUID has been erased.
Virt-sysprep can be used as part of a process of cloning guests, or to prepare a template from which guests can be cloned.  There are many different ways to achieve this using the virt tools, and this section is just an introduction.
A virtual machine (when switched off) consists of two parts:
configuration The configuration or description of the guest.  eg. The libvirt XML (see "virsh dumpxml"), the running configuration of the guest, or another external format like OVF.
Some configuration items that might need to be changed:
•   name
•   UUID
•   path to block device(s)
•   network card MAC address
block device(s) One or more hard disk images, themselves containing files, directories, applications, kernels, configuration, etc.
Some things inside the block devices that might need to be changed:
•   hostname and other net configuration
•   SSH host keys
•   Windows unique security ID (SID)
•   Puppet registration
COPYING THE BLOCK DEVICE Starting with an original guest, you probably wish to copy the guest block device and its configuration to make a template.  Then once you are happy with the template, you will want to make many clones from it.
virt-sysprep | v original guest --------> template ----------> \------> cloned \-----> guests \---->
You can, of course, just copy the block device on the host using cp(1) or dd(1).
dd                 dd original guest --------> template ----------> \------> cloned \-----> guests \---->
There are some smarter (and faster) ways too:
snapshot template ----------> \------> cloned \-----> guests \---->
You may want to run virt-sysprep twice, once to reset the guest (to make a template) and a second time to customize the guest for a specific user:
virt-sysprep        virt-sysprep (reset)      (add user, keys, logos) |                   | dd      v          dd       v original guest ----> template ---------> copied ------> custom template       guest
•   Create a snapshot using qemu-img:
qemu-img create -f qcow2 -o backing_file=original snapshot.qcow
The advantage is that you don’t need to copy the original (very fast) and only changes are stored (less storage required).
Note that writing to the backing file once you have created guests on top of it is not possible: you will corrupt the guests.
•   Create a snapshot using "lvcreate --snapshot".
•   Other ways to create snapshots include using filesystems-level tools (for filesystems such as btrfs).
Most Network Attached Storage (NAS) devices can also create cheap snapshots from files or LUNs.
•   Get your NAS to duplicate the LUN.  Most NAS devices can also duplicate LUNs very cheaply (they copy them on-demand in the background).
•   Prepare your template using virt-sparsify(1).  See below.
VIRT-CLONE A separate tool, virt-clone(1), can be used to duplicate the block device and/or modify the external libvirt configuration of a guest.  It will reset the name, UUID and MAC address of the guest in the libvirt XML.
virt-clone(1) does not use libguestfs and cannot look inside the disk image.  This was the original motivation to write virt-sysprep.
SPARSIFY virt-sparsify original guest --------> template
virt-sparsify(1) can be used to make the cloning template smaller, making it easier to compress and/or faster to copy.
Notice that since virt-sparsify also copies the image, you can use it to make the initial copy (instead of "dd").
RESIZE virt-resize template ----------> \------> cloned \-----> guests \---->
If you want to give people cloned guests, but let them pick the size of the guest themselves (eg. depending on how much they are prepared to pay for disk space), then instead of copying the template, you can run virt-resize(1).  Virt-resize performs a copy and resize, and thus is ideal for cloning guests from a template.
The two options --firstboot and --script both supply shell scripts that are run against the guest.  However these two options are significantly different.
--firstboot script uploads the file "script" into the guest and arranges that it will run, in the guest, when the guest is next booted.  (The script will only run once, at the "first boot").
--script script runs the shell "script" on the host, with its current directory inside the guest filesystem.
If you needed, for example, to "yum install" new packages, then you must not use --script for this, since that would (a) run the "yum" command on the host and (b) wouldn't have access to the same resources (repositories, keys, etc.) as the guest.  Any command that needs to run on the guest must be run via --firstboot.
On the other hand if you need to make adjustments to the guest filesystem (eg. copying in files), then --script is ideal since (a) it has access to the host filesystem and (b) you will get immediate feedback on errors.
Either or both options can be used multiple times on the command line.
Although virt-sysprep removes some sensitive information from the guest, it does not pretend to remove all of it.  You should examine the "OPERATIONS" above and the guest afterwards.
Sensitive files are simply removed.  The data they contained may still exist on the disk, easily recovered with a hex editor or undelete tool. The --scrub option can be used to scrub files instead of just deleting them.  virt-sparsify(1) is another way to remove this content.  See also the scrub(1) command to get rid of deleted content in directory entries and inodes.
RANDOM SEED (This section applies to Linux guests only)
For supported guests, virt-sysprep writes a few bytes of randomness from the host into the guest’s random seed file.
If this is just done once and the guest is cloned from the same template, then each guest will start with the same entropy, and things like SSH host keys and TCP sequence numbers may be predictable.
Therefore you should arrange to add more randomness after cloning from a template too, which can be done by enabling just the customize module:
cp template.img newguest.img virt-sysprep --enable customize -a newguest.img
For guests which make use of SELinux, special handling for them might be needed when using operations which create new files or alter existing ones.
For further details, see "SELINUX" in virt-builder(1).
WINDOWS 8 Windows 8 "fast startup" can prevent virt-sysprep from working.  See "WINDOWS HIBERNATION AND WINDOWS 8 FAST STARTUP" in guestfs(3).
This program returns 0 on success, or 1 if there was an error.
"VIRT_TOOLS_DATA_DIR" This can point to the directory containing data files used for Windows firstboot installation.
Normally you do not need to set this.  If not set, a compiled-in default will be used (something like /usr/share/virt-tools).
This directory may contain the following files:
rhsrvany.exe This is the RHSrvAny Windows binary, used to install a "firstboot" script in Windows guests.  It is required if you intend to use the --firstboot or --firstboot-command options with Windows guests.
See also: "https://github.com/rwmjones/rhsrvany"
pvvxsvc.exe This is a Windows binary shipped with SUSE VMDP, used to install a "firstboot" script in Windows guests.  It is required if you intend to use the --firstboot or --firstboot-command options with Windows guests.
For other environment variables, see "ENVIRONMENT VARIABLES" in guestfs(3).
guestfs(3), guestfish(1), virt-builder(1), virt-clone(1), virt-customize(1), virt-rescue(1), virt-resize(1), virt-sparsify(1), virsh(1), lvcreate(8), qemu-img(1), scrub(1), http://libguestfs.org/, http://libvirt.org/.
Richard W.M. Jones http://people.redhat.com/~rjones/
Wanlong Gao, Fujitsu Ltd.
Copyright (C) 2011-2020 Red Hat Inc.
Copyright (C) 2012 Fujitsu Ltd.
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
To get a list of bugs against libguestfs, use this link: https://bugzilla.redhat.com/buglist.cgi?component=libguestfs&product=Virtualization+Tools
To report a new bug against libguestfs, use this link: https://bugzilla.redhat.com/enter_bug.cgi?component=libguestfs&product=Virtualization+Tools
When reporting a bug, please supply:
•   The version of libguestfs.
•   Where you got libguestfs (eg. which Linux distro, compiled from source, etc)
•   Describe the bug accurately and give a way to reproduce it.
•   Run libguestfs-test-tool(1) and paste the complete, unedited output into the bug report.
GIT-PUSH(1)                        Git Manual                        GIT-PUSH(1)
git-push - Update remote refs along with associated objects
git push [--all | --mirror | --tags] [--follow-tags] [--atomic] [-n | --dry-run] [--receive-pack=<git-receive-pack>] [--repo=<repository>] [-f | --force] [-d | --delete] [--prune] [-v | --verbose] [-u | --set-upstream] [-o <string> | --push-option=<string>] [--[no-]signed|--signed=(true|false|if-asked)] [--force-with-lease[=<refname>[:<expect>]] [--force-if-includes]] [--no-verify] [<repository> [<refspec>...]]
Updates remote refs using local refs, while sending objects necessary to complete the given refs.
You can make interesting things happen to a repository every time you push into it, by setting up hooks there. See documentation for git- receive-pack(1).
When the command line does not specify where to push with the <repository> argument, branch.*.remote configuration for the current branch is consulted to determine where to push. If the configuration is missing, it defaults to origin.
When the command line does not specify what to push with <refspec>... arguments or --all, --mirror, --tags options, the command finds the default <refspec> by consulting remote.*.push configuration, and if it is not found, honors push.default configuration to decide what to push (See git-config(1) for the meaning of push.default).
When neither the command-line nor the configuration specify what to push, the default behavior is used, which corresponds to the simple value for push.default: the current branch is pushed to the corresponding upstream branch, but as a safety measure, the push is aborted if the upstream branch does not have the same name as the local one.
<repository> The "remote" repository that is destination of a push operation. This parameter can be either a URL (see the section GIT URLS below) or the name of a remote (see the section REMOTES below).
<refspec>... Specify what destination ref to update with what source object. The format of a <refspec> parameter is an optional plus +, followed by the source object <src>, followed by a colon :, followed by the destination ref <dst>.
The <src> is often the name of the branch you would want to push, but it can be any arbitrary "SHA-1 expression", such as master~4 or HEAD (see gitrevisions(7)).
The <dst> tells which ref on the remote side is updated with this push. Arbitrary expressions cannot be used here, an actual ref must be named. If git push [<repository>] without any <refspec> argument is set to update some ref at the destination with <src> with remote.<repository>.push configuration variable, :<dst> part can be omitted—such a push will update a ref that <src> normally updates without any <refspec> on the command line. Otherwise, missing :<dst> means to update the same ref as the <src>.
If <dst> doesn’t start with refs/ (e.g.  refs/heads/master) we will try to infer where in refs/* on the destination <repository> it belongs based on the type of <src> being pushed and whether <dst> is ambiguous.
•   If <dst> unambiguously refers to a ref on the <repository> remote, then push to that ref.
•   If <src> resolves to a ref starting with refs/heads/ or refs/tags/, then prepend that to <dst>.
•   Other ambiguity resolutions might be added in the future, but for now any other cases will error out with an error indicating what we tried, and depending on the advice.pushUnqualifiedRefname configuration (see git-config(1)) suggest what refs/ namespace you may have wanted to push to.
The object referenced by <src> is used to update the <dst> reference on the remote side. Whether this is allowed depends on where in refs/* the <dst> reference lives as described in detail below, in those sections "update" means any modifications except deletes, which as noted after the next few sections are treated differently.
The refs/heads/* namespace will only accept commit objects, and updates only if they can be fast-forwarded.
The refs/tags/* namespace will accept any kind of object (as commits, trees and blobs can be tagged), and any updates to them will be rejected.
It’s possible to push any type of object to any namespace outside of refs/{tags,heads}/*. In the case of tags and commits, these will be treated as if they were the commits inside refs/heads/* for the purposes of whether the update is allowed.
I.e. a fast-forward of commits and tags outside refs/{tags,heads}/* is allowed, even in cases where what’s being fast-forwarded is not a commit, but a tag object which happens to point to a new commit which is a fast-forward of the commit the last tag (or commit) it’s replacing. Replacing a tag with an entirely different tag is also allowed, if it points to the same commit, as well as pushing a peeled tag, i.e. pushing the commit that existing tag object points to, or a new tag object which an existing commit points to.
Tree and blob objects outside of refs/{tags,heads}/* will be treated the same way as if they were inside refs/tags/*, any update of them will be rejected.
All of the rules described above about what’s not allowed as an update can be overridden by adding an the optional leading + to a refspec (or using --force command line option). The only exception to this is that no amount of forcing will make the refs/heads/* namespace accept a non-commit object. Hooks and configuration can also override or amend these rules, see e.g. receive.denyNonFastForwards in git-config(1) and pre-receive and update in githooks(5).
Pushing an empty <src> allows you to delete the <dst> ref from the remote repository. Deletions are always accepted without a leading + in the refspec (or --force), except when forbidden by configuration or hooks. See receive.denyDeletes in git-config(1) and pre-receive and update in githooks(5).
The special refspec : (or +: to allow non-fast-forward updates) directs Git to push "matching" branches: for every branch that exists on the local side, the remote side is updated if a branch of the same name already exists on the remote side.
tag <tag> means the same as refs/tags/<tag>:refs/tags/<tag>.
--all Push all branches (i.e. refs under refs/heads/); cannot be used with other <refspec>.
--prune Remove remote branches that don’t have a local counterpart. For example a remote branch tmp will be removed if a local branch with the same name doesn’t exist any more. This also respects refspecs, e.g.  git push --prune remote refs/heads/*:refs/tmp/* would make sure that remote refs/tmp/foo will be removed if refs/heads/foo doesn’t exist.
--mirror Instead of naming each ref to push, specifies that all refs under refs/ (which includes but is not limited to refs/heads/, refs/remotes/, and refs/tags/) be mirrored to the remote repository. Newly created local refs will be pushed to the remote end, locally updated refs will be force updated on the remote end, and deleted refs will be removed from the remote end. This is the default if the configuration option remote.<remote>.mirror is set.
-n, --dry-run Do everything except actually send the updates.
--porcelain Produce machine-readable output. The output status line for each ref will be tab-separated and sent to stdout instead of stderr. The full symbolic names of the refs will be given.
-d, --delete All listed refs are deleted from the remote repository. This is the same as prefixing all refs with a colon.
--tags All refs under refs/tags are pushed, in addition to refspecs explicitly listed on the command line.
--follow-tags Push all the refs that would be pushed without this option, and also push annotated tags in refs/tags that are missing from the remote but are pointing at commit-ish that are reachable from the refs being pushed. This can also be specified with configuration variable push.followTags. For more information, see push.followTags in git- config(1).
--[no-]signed, --signed=(true|false|if-asked) GPG-sign the push request to update refs on the receiving side, to allow it to be checked by the hooks and/or be logged. If false or --no-signed, no signing will be attempted. If true or --signed, the push will fail if the server does not support signed pushes. If set to if-asked, sign if and only if the server supports signed pushes. The push will also fail if the actual call to gpg --sign fails. See git-receive-pack(1) for the details on the receiving end.
--[no-]atomic Use an atomic transaction on the remote side if available. Either all refs are updated, or on error, no refs are updated. If the server does not support atomic pushes the push will fail.
-o <option>, --push-option=<option> Transmit the given string to the server, which passes them to the pre-receive as well as the post-receive hook. The given string must not contain a NUL or LF character. When multiple --push-option=<option> are given, they are all sent to the other side in the order listed on the command line. When no --push-option=<option> is given from the command line, the values of configuration variable push.pushOption are used instead.
--receive-pack=<git-receive-pack>, --exec=<git-receive-pack> Path to the git-receive-pack program on the remote end. Sometimes useful when pushing to a remote repository over ssh, and you do not have the program in a directory on the default $PATH.
--[no-]force-with-lease, --force-with-lease=<refname>, --force-with-lease=<refname>:<expect> Usually, "git push" refuses to update a remote ref that is not an ancestor of the local ref used to overwrite it.
This option overrides this restriction if the current value of the remote ref is the expected value. "git push" fails otherwise.
Imagine that you have to rebase what you have already published. You will have to bypass the "must fast-forward" rule in order to replace the history you originally published with the rebased history. If somebody else built on top of your original history while you are rebasing, the tip of the branch at the remote may advance with their commit, and blindly pushing with --force will lose their work.
This option allows you to say that you expect the history you are updating is what you rebased and want to replace. If the remote ref still points at the commit you specified, you can be sure that no other people did anything to the ref. It is like taking a "lease" on the ref without explicitly locking it, and the remote ref is updated only if the "lease" is still valid.
--force-with-lease alone, without specifying the details, will protect all remote refs that are going to be updated by requiring their current value to be the same as the remote-tracking branch we have for them.
--force-with-lease=<refname>, without specifying the expected value, will protect the named ref (alone), if it is going to be updated, by requiring its current value to be the same as the remote-tracking branch we have for it.
--force-with-lease=<refname>:<expect> will protect the named ref (alone), if it is going to be updated, by requiring its current value to be the same as the specified value <expect> (which is allowed to be different from the remote-tracking branch we have for the refname, or we do not even have to have such a remote-tracking branch when this form is used). If <expect> is the empty string, then the named ref must not already exist.
Note that all forms other than --force-with-lease=<refname>:<expect> that specifies the expected current value of the ref explicitly are still experimental and their semantics may change as we gain experience with this feature.
"--no-force-with-lease" will cancel all the previous --force-with-lease on the command line.
A general note on safety: supplying this option without an expected value, i.e. as --force-with-lease or --force-with-lease=<refname> interacts very badly with anything that implicitly runs git fetch on the remote to be pushed to in the background, e.g.  git fetch origin on your repository in a cronjob.
The protection it offers over --force is ensuring that subsequent changes your work wasn’t based on aren’t clobbered, but this is trivially defeated if some background process is updating refs in the background. We don’t have anything except the remote tracking info to go by as a heuristic for refs you’re expected to have seen & are willing to clobber.
If your editor or some other system is running git fetch in the background for you a way to mitigate this is to simply set up another remote:
git remote add origin-push $(git config remote.origin.url) git fetch origin-push
Now when the background process runs git fetch origin the references on origin-push won’t be updated, and thus commands like:
git push --force-with-lease origin-push
Will fail unless you manually run git fetch origin-push. This method is of course entirely defeated by something that runs git fetch --all, in that case you’d need to either disable it or do something more tedious like:
git fetch              # update 'master' from remote git tag base master    # mark our base point git rebase -i master   # rewrite some commits git push --force-with-lease=master:base master:master
I.e. create a base tag for versions of the upstream code that you’ve seen and are willing to overwrite, then rewrite history, and finally force push changes to master if the remote version is still at base, regardless of what your local remotes/origin/master has been updated to in the background.
Alternatively, specifying --force-if-includes as an ancillary option along with --force-with-lease[=<refname>] (i.e., without saying what exact commit the ref on the remote side must be pointing at, or which refs on the remote side are being protected) at the time of "push" will verify if updates from the remote-tracking refs that may have been implicitly updated in the background are integrated locally before allowing a forced update.
-f, --force Usually, the command refuses to update a remote ref that is not an ancestor of the local ref used to overwrite it. Also, when --force-with-lease option is used, the command refuses to update a remote ref whose current value does not match what is expected.
This flag disables these checks, and can cause the remote repository to lose commits; use it with care.
Note that --force applies to all the refs that are pushed, hence using it with push.default set to matching or with multiple push destinations configured with remote.*.push may overwrite refs other than the current branch (including local refs that are strictly behind their remote counterpart). To force a push to only one branch, use a + in front of the refspec to push (e.g git push origin +master to force a push to the master branch). See the <refspec>...  section above for details.
--[no-]force-if-includes Force an update only if the tip of the remote-tracking ref has been integrated locally.
This option enables a check that verifies if the tip of the remote-tracking ref is reachable from one of the "reflog" entries of the local branch based in it for a rewrite. The check ensures that any updates from the remote have been incorporated locally by rejecting the forced update if that is not the case.
If the option is passed without specifying --force-with-lease, or specified along with --force-with-lease=<refname>:<expect>, it is a "no-op".
Specifying --no-force-if-includes disables this behavior.
--repo=<repository> This option is equivalent to the <repository> argument. If both are specified, the command-line argument takes precedence.
-u, --set-upstream For every branch that is up to date or successfully pushed, add upstream (tracking) reference, used by argument-less git-pull(1) and other commands. For more information, see branch.<name>.merge in git- config(1).
--[no-]thin These options are passed to git-send-pack(1). A thin transfer significantly reduces the amount of sent data when the sender and receiver share many of the same objects in common. The default is --thin.
-q, --quiet Suppress all output, including the listing of updated refs, unless an error occurs. Progress is not reported to the standard error stream.
-v, --verbose Run verbosely.
--progress Progress status is reported on the standard error stream by default when it is attached to a terminal, unless -q is specified. This flag forces progress status even if the standard error stream is not directed to a terminal.
--no-recurse-submodules, --recurse-submodules=check|on-demand|only|no May be used to make sure all submodule commits used by the revisions to be pushed are available on a remote-tracking branch. If check is used Git will verify that all submodule commits that changed in the revisions to be pushed are available on at least one remote of the submodule. If any commits are missing the push will be aborted and exit with non-zero status. If on-demand is used all submodules that changed in the revisions to be pushed will be pushed. If on-demand was not able to push all necessary revisions it will also be aborted and exit with non-zero status. If only is used all submodules will be recursively pushed while the superproject is left unpushed. A value of no or using --no-recurse-submodules can be used to override the push.recurseSubmodules configuration variable when no submodule recursion is required.
--[no-]verify Toggle the pre-push hook (see githooks(5)). The default is --verify, giving the hook a chance to prevent the push. With --no-verify, the hook is bypassed completely.
-4, --ipv4 Use IPv4 addresses only, ignoring IPv6 addresses.
-6, --ipv6 Use IPv6 addresses only, ignoring IPv4 addresses.
In general, URLs contain information about the transport protocol, the address of the remote server, and the path to the repository. Depending on the transport protocol, some of this information may be absent.
Git supports ssh, git, http, and https protocols (in addition, ftp, and ftps can be used for fetching, but this is inefficient and deprecated; do not use it).
The native transport (i.e. git:// URL) does no authentication and should be used with caution on unsecured networks.
The following syntaxes may be used with them:
•   ssh://[user@]host.xz[:port]/path/to/repo.git/
•   git://host.xz[:port]/path/to/repo.git/
•   http[s]://host.xz[:port]/path/to/repo.git/
•   ftp[s]://host.xz[:port]/path/to/repo.git/
An alternative scp-like syntax may also be used with the ssh protocol:
•   [user@]host.xz:path/to/repo.git/
This syntax is only recognized if there are no slashes before the first colon. This helps differentiate a local path that contains a colon. For example the local path foo:bar could be specified as an absolute path or ./foo:bar to avoid being misinterpreted as an ssh url.
The ssh and git protocols additionally support ~username expansion:
•   ssh://[user@]host.xz[:port]/~[user]/path/to/repo.git/
•   git://host.xz[:port]/~[user]/path/to/repo.git/
•   [user@]host.xz:/~[user]/path/to/repo.git/
For local repositories, also supported by Git natively, the following syntaxes may be used:
•   /path/to/repo.git/
•   file:///path/to/repo.git/
These two syntaxes are mostly equivalent, except when cloning, when the former implies --local option. See git-clone(1) for details.
git clone, git fetch and git pull, but not git push, will also accept a suitable bundle file. See git-bundle(1).
When Git doesn’t know how to handle a certain transport protocol, it attempts to use the remote-<transport> remote helper, if one exists. To explicitly request a remote helper, the following syntax may be used:
•   <transport>::<address>
where <address> may be a path, a server and path, or an arbitrary URL-like string recognized by the specific remote helper being invoked. See gitremote-helpers(7) for details.
If there are a large number of similarly-named remote repositories and you want to use a different format for them (such that the URLs you use will be rewritten into URLs that work), you can create a configuration section of the form:
[url "<actual url base>"] insteadOf = <other url base>
For example, with this:
[url "git://git.host.xz/"] insteadOf = host.xz:/path/to/ insteadOf = work:
a URL like "work:repo.git" or like "host.xz:/path/to/repo.git" will be rewritten in any context that takes a URL to be "git://git.host.xz/repo.git".
If you want to rewrite URLs for push only, you can create a configuration section of the form:
[url "<actual url base>"] pushInsteadOf = <other url base>
[url "ssh://example.org/"] pushInsteadOf = git://example.org/
a URL like "git://example.org/path/to/repo.git" will be rewritten to "ssh://example.org/path/to/repo.git" for pushes, but pulls will still use the original URL.
The name of one of the following can be used instead of a URL as <repository> argument:
•   a remote in the Git configuration file: $GIT_DIR/config,
•   a file in the $GIT_DIR/remotes directory, or
•   a file in the $GIT_DIR/branches directory.
All of these also allow you to omit the refspec from the command line because they each contain a refspec which git will use by default.
Named remote in configuration file You can choose to provide the name of a remote which you had previously configured using git-remote(1), git-config(1) or even by a manual edit to the $GIT_DIR/config file. The URL of this remote will be used to access the repository. The refspec of this remote will be used by default when you do not provide a refspec on the command line. The entry in the config file would appear like this:
[remote "<name>"] url = <url> pushurl = <pushurl> push = <refspec> fetch = <refspec>
The <pushurl> is used for pushes only. It is optional and defaults to <url>.
Named file in $GIT_DIR/remotes You can choose to provide the name of a file in $GIT_DIR/remotes. The URL in this file will be used to access the repository. The refspec in this file will be used as default when you do not provide a refspec on the command line. This file should have the following format:
URL: one of the above URL format Push: <refspec> Pull: <refspec>
Push: lines are used by git push and Pull: lines are used by git pull and git fetch. Multiple Push: and Pull: lines may be specified for additional branch mappings.
Named file in $GIT_DIR/branches You can choose to provide the name of a file in $GIT_DIR/branches. The URL in this file will be used to access the repository. This file should have the following format:
<url>#<head>
<url> is required; #<head> is optional.
Depending on the operation, git will use one of the following refspecs, if you don’t provide one on the command line. <branch> is the name of this file in $GIT_DIR/branches and <head> defaults to master.
git fetch uses:
refs/heads/<head>:refs/heads/<branch>
git push uses:
HEAD:refs/heads/<head>
The output of "git push" depends on the transport method used; this section describes the output when pushing over the Git protocol (either locally or via ssh).
The status of the push is output in tabular form, with each line representing the status of a single ref. Each line is of the form:
<flag> <summary> <from> -> <to> (<reason>)
If --porcelain is used, then each line of the output is of the form:
<flag> \t <from>:<to> \t <summary> (<reason>)
The status of up-to-date refs is shown only if --porcelain or --verbose option is used.
flag A single character indicating the status of the ref:
(space) for a successfully pushed fast-forward;
+ for a successful forced update;
- for a successfully deleted ref;
* for a successfully pushed new ref;
! for a ref that was rejected or failed to push; and
= for a ref that was up to date and did not need pushing.
summary For a successfully pushed ref, the summary shows the old and new values of the ref in a form suitable for using as an argument to git log (this is <old>..<new> in most cases, and <old>...<new> for forced non-fast-forward updates).
For a failed update, more details are given:
rejected Git did not try to send the ref at all, typically because it is not a fast-forward and you did not force the update.
remote rejected The remote end refused the update. Usually caused by a hook on the remote side, or because the remote repository has one of the following safety options in effect: receive.denyCurrentBranch (for pushes to the checked out branch), receive.denyNonFastForwards (for forced non-fast-forward updates), receive.denyDeletes or receive.denyDeleteCurrent. See git-config(1).
remote failure The remote end did not report the successful update of the ref, perhaps because of a temporary error on the remote side, a break in the network connection, or other transient error.
from The name of the local ref being pushed, minus its refs/<type>/ prefix. In the case of deletion, the name of the local ref is omitted.
to The name of the remote ref being updated, minus its refs/<type>/ prefix.
reason A human-readable explanation. In the case of successfully pushed refs, no explanation is needed. For a failed ref, the reason for failure is described.
NOTE ABOUT FAST-FORWARDS When an update changes a branch (or more in general, a ref) that used to point at commit A to point at another commit B, it is called a fast-forward update if and only if B is a descendant of A.
In a fast-forward update from A to B, the set of commits that the original commit A built on top of is a subset of the commits the new commit B builds on top of. Hence, it does not lose any history.
In contrast, a non-fast-forward update will lose history. For example, suppose you and somebody else started at the same commit X, and you built a history leading to commit B while the other person built a history leading to commit A. The history looks like this:
B / ---X---A
Further suppose that the other person already pushed changes leading to A back to the original repository from which you two obtained the original commit X.
The push done by the other person updated the branch that used to point at commit X to point at commit A. It is a fast-forward.
But if you try to push, you will attempt to update the branch (that now points at A) with commit B. This does not fast-forward. If you did so, the changes introduced by commit A will be lost, because everybody will now start building on top of B.
The command by default does not allow an update that is not a fast-forward to prevent such loss of history.
If you do not want to lose your work (history from X to B) or the work by the other person (history from X to A), you would need to first fetch the history from the repository, create a history that contains changes done by both parties, and push the result back.
You can perform "git pull", resolve potential conflicts, and "git push" the result. A "git pull" will create a merge commit C between commits A and B.
B---C /   / ---X---A
Updating A with the resulting merge commit will fast-forward and your push will be accepted.
Alternatively, you can rebase your change between X and B on top of A, with "git pull --rebase", and push the result back. The rebase will create a new commit D that builds the change between X and B on top of A.
B   D /   / ---X---A
Again, updating A with this commit will fast-forward and your push will be accepted.
There is another common situation where you may encounter non-fast-forward rejection when you try to push, and it is possible even when you are pushing into a repository nobody else pushes into. After you push commit A yourself (in the first picture in this section), replace it with "git commit --amend" to produce commit B, and you try to push it out, because forgot that you have pushed A out already. In such a case, and only if you are certain that nobody in the meantime fetched your earlier commit A (and started building on top of it), you can run "git push --force" to overwrite it. In other words, "git push --force" is a method reserved for a case where you do mean to lose history.
git push Works like git push <remote>, where <remote> is the current branch’s remote (or origin, if no remote is configured for the current branch).
git push origin Without additional configuration, pushes the current branch to the configured upstream (branch.<name>.merge configuration variable) if it has the same name as the current branch, and errors out without pushing otherwise.
The default behavior of this command when no <refspec> is given can be configured by setting the push option of the remote, or the push.default configuration variable.
For example, to default to pushing only the current branch to origin use git config remote.origin.push HEAD. Any valid <refspec> (like the ones in the examples below) can be configured as the default for git push origin.
git push origin : Push "matching" branches to origin. See <refspec> in the OPTIONS section above for a description of "matching" branches.
git push origin master Find a ref that matches master in the source repository (most likely, it would find refs/heads/master), and update the same ref (e.g. refs/heads/master) in origin repository with it. If master did not exist remotely, it would be created.
git push origin HEAD A handy way to push the current branch to the same name on the remote.