GitKraken usage tutorial - basic part (5)

7. Submit code

1) View file changes

After modifying a file, a list of modified files will appear on the right side of the program (as shown in Figure 1‑1). Here, take Test.git as an example, modify the file encoding of 19264.h and change it to utf8. The Unstaged Files box will appear as 19264.h

Figure 1‑1 Files not yet staged

Click this item, and the left area and central area of ​​GitKraken will become a file comparator, as shown in the figure.

Figure 1‑2 File Comparator (Diff View)

The figure shows the file in the form of Diff View , that is, it shows the current commit and the position of the file change when the last commit was made. The red sections indicate what was removed in this commit, and the green sections indicate what was added in this commit.

Click on File View next to Diff View (top right in the image) to view the file contents as a normal text display.

Here you can see that the changed part is to correctly decode all the garbled content.

2) Submit by file

After modifying the code, if you think that all the files modified this time are OK, you can save all the files into the temporary storage area, and then fill in the CommitMessage. The specific steps are as follows:

  1. Click the button on the right   (see the green button shown in Figure 1-3) to save all modified files to the staging area.

Figure 1‑3 Temporary file

If you only want to submit a few files, move the mouse to the location of the item, and a button will appear on the right, as shown in Figure 1-4, click to save this one file to the temporary storage area (Figure 1-4).

  2. After saving to the staging area, this file will appear in the staging area:

Figure 1-4 Files in the staging area

  3. Next, fill in CommitMessage (at least you need to fill in Summary), submit (commit) to the working directory, and a commit record can be generated, which is convenient for rolling back the code version or performing other operations in the future.

Figure 1‑5 Commit Message box

3) Submit part of the code in the file

When submitting code, if you do not want to submit the entire file, you can click on the Diff View of the file in GitKraken to compare the content of the previous code submission and this modification.

As can be seen from Figure 1-6, GitKraken has divided the changed code into blocks by region.

Move the mouse over the block and a button . As shown below:

 

 

Clicking will temporarily store this piece of modified content and keep the green part (that is, keep the content of +2 ~ +4 lines, discard the content of -2 ~ -4 lines),

This part of the change will be discarded, leaving the red part (keep -2 ~ -4 lines, discard +2 ~ +4 lines).

 

Take 19264.h as an example, if you keep part of the modified content and part of the content before the modification, then the file will exist in both the Unstaged Files list and the Staged Files list, because there are still parts of the file that are not. Submit to the staging area.

Starting from the submission record after the 19264.h file encoding was changed to utf8, the LCD_Send_1 function has been completely deleted in the text editor, and the red area corresponds to the deletion record of the code. If you only need to delete the switch judgment statement in the LCD_Send_1 function, that is, the -45 ~ -50 lines of code in the figure.

Figure 1-7 Delete part of the file

Notice that when the mouse moves to a row in the modification area, a  button will appear on the left side of the row, and clicking the button will confirm the modification.

Figure 1-8 Retain file modification

Now you need to keep the contents of lines -36 ~ -63, click the button , the interface will prompt: File contents are unchanged . And there is still 19264.h file in the Unstaged Files list,

Click the  button to the right of the file in the list to submit the file to the staging area. The following will be submitted:

Figure 1-9 Files in the staging area

It can be seen that compared with the previous file (referred to as A1), the file to be submitted (referred to as A2) is missing 45~50 lines in A1, fill in the Commit Message, and submit it to the working directory. Looking at it in a text editor, you can see that the switch statement in the LCD_Send_1 function has been removed.

Guess you like

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