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

What is the difference between git push and commit

WBOY
Release: 2022-06-24 15:01:25
Original
10441 people have browsed it

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 :If the local branch name is the same as the remote branch name, You can omit the colon:

git push

Example

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

$ git push origin master
Copy after login

Equivalent to:

$ git push origin master:master
Copy after login

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]
Copy after login

[message] can be some remarks.

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

$ git commit [file1] [file2] ... -m [message]
Copy after login

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

$ git commit -a
Copy after login

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!

Related labels:
git
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template