In git, "push -f" means "forced update" and is the abbreviation of "push -force". The function of this command is to push the code of your local warehouse directly to the warehouse, completely based on This command will be submitted upon submission, and all previous submissions will be overwritten.
The operating environment of this article: Windows 10 system, Git version 2.30.0, Dell G3 computer.
What does push -f mean in git
First let’s take a look at what the command git push -f means:
1. Run gif push -h
2. Find the -f parameter, which is actually the abbreviation of the --force parameter.
This command actually means forced update! When you use git push to push and report an error, in addition to patiently troubleshooting the error before pushing, you can also use this command to force the push, but usually this will cause serious consequences!
Let's demonstrate the "powerful" power of this command through this experience. First, let's take a look at the commit of the branch mileStone we want to demonstrate on the remote warehouse. Record the information. The operation is as follows:
1. Log in to GitHub
2. Enter the warehouse and switch to the branch mileStone
icon. We have a total of 25 submissions on this branch. Record, click to enter the submission record details page, where you can see all submission details.
We will demonstrate later that through the git push -f command, all submission records can be completely deleted!
Run the following command to see the effect:
1. git push -f remote warehouse alias branch name
The forced push was successful ! (Illustration)
# Let’s take a look at the contents of the remote warehouse. As can be seen from the illustration, all 25 submission records that originally existed under the mileStone branch of the remote warehouse have been deleted. deleted!
Recommended study: "Git Tutorial"
The above is the detailed content of What does push -f mean in git?. For more information, please follow other related articles on the PHP Chinese website!