Git Bash Not Recognizing Changes

I’m learning about git commands at the moment and i understand the commands for the most part, my only question at the moment is how and where do i make the changes to a file in order for git to register the changes? I have set the repository and added the file. But do i go into the file, make a change then go back to git and add the file again? Because when i do, even if i add a line AND save, then add it, when i use “git diff” nothing pops up. it doesn’t see that i have made changes.

What two things did you diff? You left that to the default behaviour right? So which two things did it compare by default and did you make those two things be different?

When you’re editing a file, you are not “in the file”. Your editor is displaying some text. What’s in the file is what sits on the disk, your edits only end up in the file after you’ve told your editor to save the content.

git does not pay attention to when you write to a file or what you do in a text editor.

you can add files to git’s staging area, and from that make a commit when you’ve added all changes that you want your commit to consist of.

if you want to diff two things, then unless you want to diff the two things that git diffs by default when you don’t specify anything, then you will need to specify the two things you wish to diff.

3 Likes

Well in the lesson itll say to add a line to which it shows at the top something like “scene-1.txt”. so i add a line to scene-1.txt, do “git add scene-1.txt”, then i just type git diff scene-1.txt to see what changes were made. and it showed the new line that was added. i didnt have to specify anything. but also okay so if i dont edit through the text editor how would i add stuff to the text file like i am doing in the lessons. Heres The Lesson

Also as a side note, in git bash when i try to commit from my personal git bash app, i get a user name error. saying to specify my name.

No you would use a text editor to edit text files. The point is git has nothing to do with that.

You can specify a name when you make a commit or in a configuration file (https://git-scm.com/docs)

If you add your changes and then run git diff with no arguments, then you’ll get no changes showing up, because you eliminated the difference between the two things you’re comparing. If you get a difference anyway then you did something else. (if you make b the same as a and then compare a to b then you’ll have no difference)

4 Likes