Git 提交表示未提交任何更改

Git commit saying no changes commited

好的。所以我从我的大学老师那里得到了分叉的存储库。我需要更改 main.cpp,然后提交并推送更改。我做过这样的事情:

git config --global user.name "username" 和电子邮件一样

ssh-keygen -t rsa -b 4096 -C "email"

eval "$(ssh-agent -s)"

ssh-add ~/.ssh/id_rsa

然后我做了:git clone adress (SSH)。文件已正确复制。我编辑了我的 main.cpp,保存了更改,然后做了:git commit -m "Solution"git push。这是我的终端:

我在这里编辑 main.cpp。那么:

我做错了什么?

您首先需要暂存文件以供提交。在 this tutorial.

中了解有关 git 分期的更多信息

The git add command adds a change in the working directory to the staging area. It tells Git that you want to include updates to a particular file in the next commit. However, git add doesn't really affect the repository in any significant way—changes are not actually recorded until you run git commit.

在你的例子中,就在提交之前:

git add main.cpp

修改源代码后,您需要做

git add .
git commit -m "Solution" 

上传您提交到远程

git push origin yourbranch