1. Configure user information in git.
Enter the following command settings in the command line. You only need to set the settings once.
Git config -- global user. Name "Joey joejoe"
Git config-global user. Email "joey@joejoe.com"
2. initialize the project
The following operations are performed in the main directory of the project. The project files can be extracted from the tar.gz and ZIP files or created by yourself.
CD myproject/
Run the initialization command
Gitinit
Add all files in the current directory to git
Gitadd.
Submit update
Git commit
This will prompt you to write the submitted information, which is used to describe the content just submitted for future query. The initial commit can be written here.
Save and exit.
3. General Workflow
Generally, follow these steps:
A. Write or update the program in the project.
B. Check the changed files.
Git status
C. Check the actually changed files.
Git diff
D. Add the files or directories or other new files seen in B to the GIT repository.
Git add file1 newfile2newfolder3
E. Confirm submission,
Git commit
F enter the submission information. If the change is abandoned, exit the editor.
4. view the project status
View the current work
Git log
View the last three submissions
Git log-N3
Complete viewing
Git log -- stat -- Summary
5. View changes
View submitted updates
Git diff
View the ID of the change, for example
Git log-pretty = oneline
Bytes ---------------------------------------------------------------------------------------------------------------
6c93a1960072710c6677682a7816ba9e48b7528f removepersist. clearscriptcache ()
C6e7f6e685edbb414c676df259aab989b617b018 makegit ignore logs directory.
8fefbce334d30466e3bb8f24d11202a8f51_1c initialcommit.
Bytes ---------------------------------------------------------------------------------------------------------------
The first 40 letters of each line are the updated idnumber. These numbers will also appear when git commit is executed. The difference between the two changes is that you need to use it. For example, when judging the differences between update point 1 and update Point 2:
Git diff 8fef .. c6e7
It can be seen that 40 letters do not need to be entered in all, but only the first few digits can mark an update point.
To view the last update point, you can use:
Git diff head ^ .. head
6. Fix errors
The changes have not been submitted and you do not want them. In this case, you can discard these changes:
Git reset -- hard
You can also perform such operations on a single file, but the commands are a bit different:
Git checkout myfile.txt
In the previous submission, I forgot to add some files. You can easily correct them:
Git reset-soft head ^
Git add forget.txt test.txt
Then submit.