亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

The difference between git commit -m and git commit -am
為情所困
為情所困 2017-05-02 09:36:32
0
3
1207

Please tell me the difference between git commit -m and git commit -am

為情所困
為情所困

reply all(3)
迷茫

When the modification has been approvedgit add <change file>將其添加到stage,可以通過git commit -m "<message>"為這所有已經進入stage的改變添加一個commit信息。什么是在stage? See below

If your file has been submitted before, but this time the changes have not been made stage, as follows:

You can directly use git commit -am "<message>" to add all modifications but not git commit -am "<message>",將所有修改,但未進stage的改動加入stage,并記錄commit信息。(某種程度上相當于git addgit commit -m的組合技,前提是被改動文件已經是trackedto

, and record the commit information. (To some extent, it is equivalent to the combination of git add and git commit -m, provided that the modified file is already tracked)??
給我你的懷抱
git commit -am "str"
#等同于
git commit -a -m "str"

Let’s run it

man git commit 

To get the meaning of the a parameters, you will know the difference.

OPTIONS
-a, --all
Tell the command to automatically stage files that have been modified and >deleted, but new files you have not told Git about are not affected.

means

Automatically put all currently modified and deleted files on the stack, but those you have not added will not be affected.

Expand

Usually when we submit git

git add .
git commit -m "some str"
git push

These three big steps, but in fact, you only need two commands, unless there are new files to be added.

git commit -am "some str"
git push
伊謝爾倫

Literally explained, git commit -m is used to submit files in the staging area; git commit -am is used to submit tracked files

To understand their differences, you must first understand the file status change cycle of git, as shown in the figure below

All files under the working directory are in these two states: tracked or untracked. Tracked files refer to files that have been included in version control management. They are recorded in the last snapshot. After working for a period of time, their status may be not updated, modified or placed in the staging area

The following is an example

When a new file such as 'a.txt' is added to the project folder, the file is in an untracked state. Files in untracked status cannot be submitted

Next, use git add a.txt to make it tracked

At this time, if you use git commit -m 'add a.txt', you can submit it smoothly

But what is the difference between git commit -m and git commit -am? It depends on the processing after modifying the a.txt file

Next, add content 'a' to a.txt

The file a.txt is tracked but not staged. At this time, if you use git commit -m, you cannot submit the latest version of a.txt. What is submitted is only the old version of a.txt with empty content at the beginning

To submit a new version of a.txt, that is, a.txt with the content 'a', you need to use git add a.txt to put the new version of a.txt into the staged temporary storage area, and then use git commit -m Make a submission

If you use git commit -am, you can omit the step of git add a.txt, because git commit -am can submit the tracked file, and a.txt has already been tracked from the beginning

In summary, the key to the difference between using these two commands is the git add command

The git add command is a multi-functional command. Depending on the status of the target file, the effect of this command is also different: you can use it to start tracking new files, or to put tracked files into the temporary storage area, and it can also be used to merge files. Conflicted files are marked as resolved status etc.

We need to use the git add command to track new files, but if you use git commit -am, you can omit the function of using the git add command to put the tracked files into the staging area

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template