Home >Development Tools >git >What does push -f mean in git?

What does push -f mean in git?

WBOY
WBOYOriginal
2022-01-04 17:10:0624761browse

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.

What does push -f mean in git?

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!

What does push -f mean in git?

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!

What does push -f mean in git?

Run the following command to see the effect:

1. git push -f remote warehouse alias branch name

The forced push was successful ! (Illustration)

What does push -f mean in git?

# 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!

What does push -f mean in git?

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn