Using git add and git commit


<Below this line, add a link to the EXACT exercise that you are asking about.>
Hello, this is my first post so thank you in advance for being gentle!

Here is a link to the lesson I’m currently on. It is from “How to Backtrack: Lesson 3: slide 3”. Let me know if I can post this in a better fashion (can I use HTML within the comment to create a hyperlink? How would I do that…?)

<Below this line, describe in what way does your code behave incorrectly? Include ALL error messages.>

I’m having difficulty understanding what I need to be doing to add/commit changes to a file. I was able to “git add scene-5.txt” then "git commit -m “balloons change” but now I can’t seem to commit anything else. I’ve tried to change the text in the editor and then commit new changes (“git add scene-5.txt” then "git commit -m “next balloons change” or "git commit -m “balloons change”) but I keep receiving the message:

“On branch master
nothing to commit, working directory clean”

I’ve used “dir” to verify that I can see scene-5.txt and it is there along with the other scenes. I’m also able to “git log” and “git show HEAD” but I can’t seem to commit anything new.

Related: do I need to enter “git add ‘filename’” each time before I make a commit? Also, do I need to keep the same commit name or do I need to change it each time?

Thanks in advance for your help!

<Below this line, add a screenshot of your whole web browser so that we can see what you see.>

The closest thing a commit has to a name is its hash, and usually it’s considered a good idea to describe what it changes. You probably aren’t making the same change twice so two commits probably won’t have the same commit messages.

If it tells you there’s nothing to commit then you haven’t staged any changes. You would need to add it.

You can immediately, as in, without adding, commit an already tracked file by specifying the file, but that doesn’t make any difference, it’s the same action.

If you don’t know what’s staged then you can use git status to find out, it’ll likely tell you there’s nothing staged since you’re getting “nothing to commit, working directory clean” when you try to commit.

Also, you could share your directory to share the current state of your repository along with an explanation of what you’re trying to do from that state and somebody could look at it:

cd ~
tar -cz myworkspace > myworkspace.tgz
curl --upload-file myworkspace.tgz
# you'd get a link to your file
cd - # go back to the directory you were in

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.