I had some changes done in a cloned repo and now I am trying to commit and push the project. But the changes displayed in the commit section all start with '#'. So do I remove the # for the work to be saved or I leave it that way and either way still saves everything I have done?
Asked
Active
Viewed 58 times
0
-
Standard automatic ”cleanup“ is for those lines to be removed, yes. – Guildenstern Apr 18 '23 at 22:50
-
so my changes get removed too? @Guildenstern – Horthman Odame Apr 18 '23 at 22:58
-
Not all the messages in your commit, just the comments at the top of the file. You can write your commit below and you should be fine. You can check you commit afterwards Here's an example: https://i.stack.imgur.com/PQBK3.png (from [this kinda unrelated post](https://stackoverflow.com/questions/16122234/how-to-commit-a-change-with-both-message-and-description-from-the-command-li)) – Christian Apr 18 '23 at 23:00
-
@Christian so I should ignore the sign next to the changes and it wont revert back the changes? – Horthman Odame Apr 18 '23 at 23:02
-
Hard to tell without an example, check the screenshot in my comment and the answer below. If you are still unsure, edit your post and add an example, so that we can explain based on your specific case. – Christian Apr 18 '23 at 23:03
-
Cool. Here's a sentence I have deleted before: `#` indicates comments. They are not committed and do not afffect your commit. You can also accept the answer below, as it says the same. – Christian Apr 18 '23 at 23:06
1 Answers
1
If you're talking about what appears in your editor while running git commit
:
# Please enter the commit message for your changes. Lines starting
# with '#' will be ignored, and an empty message aborts the commit.
#
# On branch branch_name
# Changes to be committed:
# (etc.)
then those lines are for your information only. They won't be included in the commit message, so you don't need to worry about removing them.
You can also skip that screen with git commit -m "Commit message goes here"
, if you want. The net result will be the same either way.

Jim Redmond
- 4,139
- 1
- 14
- 18
-
Good answer. I also tend to use the `-m` option (because we squash all commits at merge anyway) but there's a good reason for not using `-m`, maybe depending on how you treat single commits, see [Write better commit messages](https://www.freecodecamp.org/news/how-to-write-better-git-commit-messages/). – Christian Apr 18 '23 at 23:09
-
1I skip `-m` for large and/or complicated commits, because the `Changes to be committed:` list helps me confirm that I'm including exactly what I want in this commit. Otherwise, though, `-m` is my preferred way to go. – Jim Redmond Apr 18 '23 at 23:20