Answer the question
In order to leave comments, you need to log in
Why does a git add command overwrite the line and a new change, and not just add a new change?
Why, after the git add command, the line is overwritten, and not just a new change is added:
1 file changed, 2 insertions (+), 1 deletion (-)
in the git hub it looks like this:
I understand correctly that only the new change should be highlighted in green in the github commit, but for some reason I delete the previous line and also add it in green... Help plz.
ps in the example, the change was - adding a new line with the number 4
Answer the question
In order to leave comments, you need to log in
See the red sign? This is the reason. In the last line of text, it is desirable to always press Enter to add a newline character. GitHub even specifically tags these places.
Lines without a break at the end are bad for Git. Since if you want to add a new line to the file, you will first have to add a hyphen character to the end of the last line, i.e. CHANGE. This change will be visible in history, although formally, it would seem, nothing has changed. It's confusing to see real changes.
So ALWAYS add a break on the last line of code. In most editors, this looks like adding an empty line at the end, but in fact there is no "extra" line, it's a phantom.
If you look through GitHub, then there is no longer an empty line.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question