git code commit management

Unit conversion of time

1 second = 1000 milliseconds (ms) 1 millisecond = 1/1,000 seconds (s)
1 second = 1,000,000 microseconds (μs) 1 microsecond = 1/1,000,000 seconds (s)
1 second = 1,000,000,000 nanoseconds (ns ) ) 1 nanosecond = 1/1,000,000,000 second (s)
1 second = 1,000,000,000,000 picosecond (ps) 1 picosecond = 1/1,000,000,000,000 second (s)

 

code submission

There are generally five steps to code submission:

1. View the modification status of the current code

2. View the code modification content

3. Temporarily store the documents that need to be submitted

4. Submit staged files

5. Sync to server

1. View the modification status of the current code

Before submitting the code, you should first check the changes made so far and run the git status command

a) has been temporarily stored (changes to be committed)

 

new file //represents a new file

Modified // means to modify the file

deleted // means to delete the file

b) changed (changed but not updated)

 

Modified // means to modify the file

deleted // means to delete the file

In addition, git gives possible operation commands, git add/rm, gitcheckout --

c) untracked files

 


2. View the content of the code modification

 git diff  <file>

Compare the diff of a file to the most recently committed node.

Note: If the file is already staged, then git diff --cached <file> should be used

 git diff <hashcode> <hashcode>  <file>

Compare the difference between a file submitted at node a and node b.

Tip: If you omit the last hashcode, the default is to compare with the previous submission node. (You can also use the ^ operator)

 

3. Temporarily store the documents to be submitted

If it is a new file

则git add  <file>

If it is a modified file then git add <file> If it is a deleted file then git rm <file>


4. Submit staged files

git commit

Pay attention to the specifications for filling in comments.

git commit --amend

Modify the most recent commit. Sometimes this command can be used if the commit comment is wrongly written or the file is omitted.


5. Sync to server

Before synchronizing to the server, you need to synchronize the server code to the local

Command: git pull

If this fails, follow the prompts to restore the conflicting files and try syncing again.

Command: git checkout -- <conflicting file path>

Sync to server

Command: git push origin <local branch name>

If the execution fails, it is generally caused by not synchronizing the server code to the local, execute the above git pull command first.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326071886&siteId=291194637