Home  >  Article  >  Development Tools  >  What is the difference between git push and commit

What is the difference between git push and commit

WBOY
WBOYOriginal
2022-06-24 11:19:0010369browse

The difference between git push and commit: 1. Push refers to pushing the code of the local warehouse to the server, while commit refers to submitting local modifications to the local library; 2 , the push operation is the local library, and the submission operation is the remote library.

What is the difference between git push and commit

The operating environment of this article: Windows 10 system, Git version 2.30.0, Dell G3 computer.

What is the difference between git push and commit

1. Push (push): Push the code of your local warehouse to the server, and send the latest information in the local library to the remote library.

Commit: Save the changes you made to the local warehouse, and submit the locally modified files to the local library.

2. git commit operates on the local library, and git push operates on the remote library.

Extended knowledge:

The git push command is used to upload the local branch version to the remote and merge it.

The command format is as follows:

git push dfe3b6942e25cbfb69aed769a10136a8 31112c17a50b8ae28f801298c3cfb58f:553386e71438f241bbce82baf48b3c26If the local branch name is the same as the remote branch name, You can omit the colon:

git push dfe3b6942e25cbfb69aed769a10136a8 31112c17a50b8ae28f801298c3cfb58f

Example

The following command will push the local master branch to origin The host's master branch.

$ git push origin master

Equivalent to:

$ git push origin master:master

The git commit command adds the contents of the staging area to the local warehouse.

Submit the staging area to the local warehouse:

git commit -m [message]

[message] can be some remarks.

Submit the specified files in the temporary storage area to the warehouse area:

$ git commit [file1] [file2] ... -m [message]

-a Parameter settings do not need to execute the git add command after modifying the file, just submit it directly

$ git commit -a

Recommended learning :《Git tutorial

The above is the detailed content of What is the difference between git push and commit. 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