0

我正在学习 Git 并且还在 Mac 终端上苦苦挣扎(我最近更换了操作系统)

我成功地在我的计算机上安装了 Git,并且我能够将我的项目推送到 Github,但现在我无法将我正在处理的相同文件(index.html)添加到我的下一次提交并得到休闲错误:

fatal: pathspec 'index.html' did not match any files

index.html 在同一个文件夹中,所以我必须更改 git 设置,但我不知道如何重新建立我所拥有的。

这是我可以使用 git config 解决的问题,我需要包含文件的路径吗?

如果我输入 git status ,我会得到以下不正确的信息。

On branch master
# Changes not staged for commit:
#   (use "git add <file>..." to update what will be committed)
#   (use "git checkout -- <file>..." to discard changes in working directory)
#
#   modified:   Documents/first_git_project/index.html
#
# Untracked files:
#   (use "git add <file>..." to include in what will be committed)
#
#   .CFUserTextEncoding
#   .DS_Store
#   .Trash/
#   .bash_history
#   .bash_profile
#   .bashrc
#   .cups/
#   .git-completion.bash
#   .gitconfig
#   .npm/
#   .nvm/
#   .ssh/
#   .viminfo
#   Desktop/
#   Documents/.DS_Store
#   Documents/.localized
#   "Documents/I\342\200\231m in the process of learning Git and working with the Mac Terminal.docx"
#   Documents/Microsoft User Data/
#   Documents/RDC Connections/
#   Documents/Symfony_quick_tour_2.2.pdf
#   Documents/Terminal Cheatsheet for Mac.docx
#   Documents/first_git_project/ first_file.txt
#   Documents/first_git_project/.DS_Store
#   Documents/first_git_project/css/
#   Documents/first_git_project/fancybox/
#   Documents/first_git_project/font/
#   Documents/first_git_project/img/
#   Documents/first_git_project/imgs/
#   Documents/first_git_project/js/
#   Downloads/
#   Library/
#   Movies/
#   Music/
#   Pictures/
#   Projects/
#   Public/
#   SublimeProj/
#   kno-engage-ui/
no changes added to commit (use "git add" and/or "git commit -a")
isaiass-MacBook-Pro:~ isaias$ 
4

1 回答 1

1

Git(实际上与许多其他工具一样)期望您提供正确的路径:

git add Documents/first_git_project/index.html #if you're in the project root folder
于 2013-07-25T19:28:30.707 回答