由于git状态中存在已删除的文件,无法进行推送。

huangapple go评论82阅读模式
英文:

Unable to push due to git status deleted files?

问题

我会直接了当地说。

我的教授指导我们将我们的第一个文本文件推送到git网站上。然后她给了我们一个个人任务,我们将推送另一个文件,但只能使用git add、git commit -m "text"和git push origin master(这是她说的,因为这是我们唯一需要使用的命令)。每当我使用git status时,下面的图片就会出现,这可能阻碍了我的推送能力。有什么建议可以解决这个问题吗?

由于git状态中存在已删除的文件,无法进行推送。

我尝试了git checkout --和建议的命令git restore 。但是两者都只生成了另一个命令行,当我们使用git status确认时,问题仍然存在。

英文:

I will be straightforward.

My professor guided us at pushing our very first text file to the git website. She then gave us an individual activity where we will push another, but should only use git add., git commit -m "text", and git push origin master (that is what she said because that's all we have to use). Whenever I use git status, the image below shows up which probably hinders my ability to push. Any tips on how I can fix this?

由于git状态中存在已删除的文件,无法进行推送。

I tried git checkout -- and doing the suggested command which is git restore <file here>. When doing both, it just generated another command line, and when we confirmed it using git status, it is still there.

答案1

得分: 1

当你使用git status命令时,你会得到自上次提交以来所做的更改。在你的情况下,它告诉你你所做的更改是删除了文件../activities/aboutme.txt。如果你修改或删除了其他文件,再次运行git status命令时会显示出来。

如果你想保留那个文件,只需运行git restore ../activities/aboutme.txt命令。如果你想提交删除了的文件,运行git add ../activities/aboutme.txt命令。如果你只想添加所有的更改,运行git add .命令,不过你需要进入项目的根目录,因为从图片上看,你似乎不在项目的根目录下。

希望对你有所帮助。

英文:

When you use git status you get the changes you've made since the last commit, in your case it is telling you that the changes you made are that you deleted the file file ../activities/aboutme.txt, if you were to modify or delete any other file then that would show up if you run git status again.

If you want to keep that file you just need to run git restore ../activities/aboutme.txt, if you want to commit that you deleted the file then run git add ../activities/aboutme.txt or if you just want to add all the changes you've made run git add ., although you would have to move to the root directory, since on the picture it looks like you are not on the root directory of your project.

Hope this helps.

答案2

得分: 1

好的,以下是翻译好的内容:

嗯,git没有问题!我猜你之前有一个名为aboutme.txt的文件,并且将其推送到了你的代码库中,现在你已经删除了那个文件,这就是为什么git status会显示那个信息。如果你想恢复被删除的文件,你应该按照以下顺序运行这两个命令:

git reset HEAD
git checkout -- .

但是如果你想提交已删除的文件,只需使用以下命令:

git add .
git commit -m "Text file deleted"
git push
英文:

Well, there's nothing wrong with git! I suppose you had a file named aboutme.txt and you've pushed it to your repository before and now you've deleted that file and that's why git status gives you that thing. If you want to restore the deleted file you should run these two commands in order:

git reset HEAD
git checkout -- .

But if you want to commit the deleted file just use these commands:

git add .
git commit -m &quot;Text file deleted&quot;
git push 

答案3

得分: 0

似乎您使用了git rm命令删除了文件,并且由于在sit状态中显示,您没有提交该文件。请使用git commit命令提交它。它将从您的跟踪器中删除。

英文:

It seems you deleted your file by using git rm command and didn't commit it due to that showing on sit status. Please commit it by using git commit command. It will be remove from your tracker

huangapple
  • 本文由 发表于 2023年8月9日 13:12:06
  • 转载请务必保留本文链接:https://go.coder-hub.com/76864756.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定