Question

I checked out an existing branch, lessons, and started to change some files, and deleted one.

After doing git add . and git commit, some changes where committed, but others were separated at the end of comment text. As far as I understand, I have to do some operation manually.

So, for the deleted file I did git rm file.name. I got this part.

What should I do with lines 14-17?

All those files were created much earlier, there are not new.

Thank you very much!

  1 
  2 # Please enter the commit message for your changes. Lines starting
  3 # with '#' will be ignored, and an empty message aborts the commit.
  4 # On branch lessons
  5 # Changes to be committed:
  6 #   (use "git reset HEAD <file>..." to unstage)
  7 #
  8   deleted:    ../layouts/]
  9 #
 10 # Changes not staged for commit:
 11 #   (use "git add <file>..." to update what will be committed)
 12 #   (use "git checkout -- <file>..." to discard changes in working directory)
 13 #
 14 # modified:   ../courses/show.html.slim                                                                                                   
 15 # modified:   ../layouts/_header.html.slim
 16 # modified:   ../student_levels/_student_level.html.slim
 17 # modified:   ../subjects/_subject.html.slim
 18 #
Was it helpful?

Solution

If I understand your situation correctly, the commit you want to make consists of modifications on some existing files and removal of some others.

The output that you have included looks like what git status would show if you tried to execute git rm -r on the folder you wanted to delete. To include the rest of your modifications you can try executing git add -u, which tells Git include to all changes to existing files that you have made into the commit. After that, executing a git commit should commit both your modifications and desired removal of files.

Also, note that git commit -a (without having used git add or git rm previously) automatically includes modifications to all known files and also specifies removal of all files no longer in your working directory. See the manual page for the commit command if you need clarification at this link.

OTHER TIPS

'git add .' would only stage the files in the current folder and below.
Not the files from line 14 to 17, which are in another folder.

git add (or for the deletions as well git add -A, starting git 2.0), without the final dot, would stage the files from the all working tree.

And I wouldn't recommend git commit -a:

  • Always stage first (git add or even git add -p to add chunks within a file)
  • Check your status (git status), make sure what you actually wanted is staged.
  • Then git commit.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top