A small problem when github uses the "git commit -m" command

git commit -m use problem

Submit the file to github today, the steps are:

  1. git add abc.py (abc.py is a file name I currently write at will)
  2. git commit -m 'add codes for abc'
  3. git push origin

In the second step, an error occurs, the error is as follows:

D:\tensorflow>git commit -m ' add codes for abc'
error: pathspec 'add' did not match any file(s) known to git.
error: pathspec 'codes' did not match any file(s) known to git.
error: pathspec 'for' did not match any file(s) known to git.
error: pathspec 'abc'' did not match any file(s) known to git.

There is no problem with the grammar, and it is always impossible to submit. Finally, I found that in the Linux system, the commit information is included with single quotation marks ''. In the Windows system I use, the information should be included in double quotation marks "", that is, the correct format of the second step command isgit commit -m "add condes for abc"

And some other questions

When analyzing the above problem, I found several useful commands:

  • git commit --amend
    • This command will commit with the current staging area snapshot. If you just submitted without any changes, running this command directly is equivalent to having the opportunity to re-edit the submission description , but the snapshot of the file to be submitted is the same as the previous >. After starting the text editor, you will see the description of the last submission, edit it to confirm that there is no problem, save and exit, and the new submission description will be used to overwrite the wrong submission.
    • If you forgot to temporarily save some changes when you just submitted, you can make up the temporary operation first, and then run --amend. The submission steps are:
      • $ git commit -m 'initial commit'
      • $ git add forgotten_file
      • $ git commit --amend
  • git reset
    • The file is rolled back from the temporary storage area to the work, which is the execution of the rollback git addcommand. The difference is git commit --amendthat this command is more inclined to cancel the last submission of the temporary storage area, and git commit --amendis more inclined to modify the submission description.
    1. git reset HEAD filename
      • Roll back the file with the specified name, roll back the file from the staging area to the workspace // you can also use git reset filename
    2. git reset -q
      • Will not reset the reference, let alone change the workspace, but use the specified commit status (

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325196618&siteId=291194637