gitgitlab

Gitlab push see 75 Additions and 30 Deletions while creating merge request


After Gitlab push I see 100 Additions and 30 Deletions, and 8 changed files. While I made only changes to 8 files, not deleted/added any file.

Is it because my local branch is behind master Or some other reason.

If so how I can pull latest changes to my branch without affecting my local changes. Any help appriciated


Solution

  • Git only understands "added" and "deleted", it's up to you to infer that deleting one line and adding a new line basically means "this line changed".

    It's trivial to test locally:

    $ mkdir demo
    $ cd demo
    $ git init
    $ printf '%s\n' line1 line2 line3 line4 > file.txt
    $ git add file.txt
    $ git commit -m 'initial commit'
    $ printf '%s\n' line1 changed2 changed3 line4 > file.txt
    $ git add file.txt
    $ git commit -m 'changing two lines'
    $ git show --stat
    commit f4d49adbdf1a3279b892ad6852faf4d59177e4c6 (HEAD -> master)
    Author: A U Thor <author@example.com>
    Date:   Wed Jul 10 14:06:26 2024 +0200
    
        changing two lines
    
     file.txt | 4 ++--
     1 file changed, 2 insertions(+), 2 deletions(-)