GitHub offers a good graphical client on both Windows and Macs, with UI style savings and features that are easy to use. But we still need to be familiar with GIT commands to maintain code, such as Linux.
Five steps to borrow the Git commit code summarized by @sunshyran:
- To view the modified state of the Code
- See what's changed in the code
- Staging code that needs to be submitted
- Submit a file that has been staged
- Sync to Server
STEP1, viewing the modified state of the Code
Open git shell (environment: Take windows as an example, install GitHub client and configure account information), default is the workspace path in Git, The LS command can view all directories under workspace (recommended: The directory under workspace should be in project), and the CD command enters the target project.
git status
The red font is a status indicator for changes in the project:
Modified represents a file that has been modified compared to the previous version
The new file represents the newly added
Deleted the file is deleted, the file will be deleted from repository after successful submission
untracked file means that files are not processed
STEP2, see what's changed in the code
git diff <filename>
Here you see the changes in the. gitignore file.
To view historical changes, you need to use the node Hashcode (Hashcode can be obtained from the commit record on GitHub):
git diff
STEP3, staging the code to be submitted
Add a file that needs to be uploaded:
git add <filename>
To delete an unwanted file:git rm <filename>
Add all the files you need to upload:git add--all
STEP4, submitting files that have been staged
Git commit-m <comment>
If a file is found to be missing or commented incorrectly, use amend to fix it:git commit--amend-m <meg>
Note: Using the commit command simply commits the modifications to the local repositorySTEP5, synchronizing to the server
Use the push command image to push the changes to GitHub's code server so that you can access the codes anywhere.
Git push-u Origin Master
Congratulations, you have successfully synced the code to the GIT server.
The document is designed to help git beginners easily use git command to commit code to a git server, such as creating libraries and conflict processing, branching and other advanced knowledge This article is not too much elaboration.
Easily submit code with GIT commands