[Solved] Push to gitlab problem

Discussion in 'Programming' started by DrOreo002, Jan 11, 2019 at 2:28 PM.

  1. So I recently working with a gitlab plugin project, this is my first time using it and I see a lot of problem when trying to push something to the gitlab repo (This will not happen in github)

    So basically, I made a few lines of changes and then the intelliJ recognize those changes (If you use intelliJ, you should know those change preview when committing the file). So I pushed it to the repo normally using ctrl+ shift + k, but when I see the changes that I made on gitlab it shows that I've deleted the whole text inside the file and then replace it with a new one (Same like ctrl+a and delete).

    I didn't have any proof for the first problem tho. But I have some screen shoot that will explain you further

    So I added ThisIsATestPush: "Test push" inside the lang.yml file. From intelliJ's view it said that I've added only 1 line, which is ofc the right one. But when I push it to gitlab, it shows that I've deleted Treasure_Item_Transfer_Failed and pasted it back in. Which is really strange...

    Soo do you guys have any idea why is this happening to me?, thx. Also my english sucks, sorry for those grammars heh
  2. The reason is quite simple:
    You have changed line 462 by appending a line break to the end of it.

    To avoid this just (always) add an empty line at the end of the file. Then you also get rid of the "No newline at ..." information
    • Like Like x 1
  3. Ooo alright. I'll try to add a new line at the end of the file on my new push. I'll inform here if its working, thanks!
  4. Alright, it seems like by adding a new line at the end of the file solved this problem for me. Not sure if its going to come back tho, but thanks for the help anyways I appreciate it!
  5. The answer above is correct. This happens because by the Unix definition, a text file is a bunch of lines, and a line is a bunch of characters that ends with a newline. Since Git counts lines changed, and follows these guidelines, it does not recognize the very last line as a line but instead as a trailing bunch of bits. By adding another line to the end of the file, Git thinks you deleted the trailing bunch of bits, and added some lines of text in its place.

    Generally, end your text files with a newline. Most tools don't really care but sometimes it might cause weird behaviour.
    • Informative Informative x 1
  6. Okay. The problem is back again, by adding new line at the end of the file didn't fix the problem. This also happens when I edit a file that I've never edited when I download the project from gitlab

Share This Page