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.
The operating environment of this article: Windows 10 system, Git version 2.30.0, Dell G3 computer.
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
git push
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!