我对一些文件运行 git rm ,认为它们将从 bitbucket 存储库中删除,并且我也提交了它们,之后我检查它们是否从 bitbucket 存储库中消失,但它们也从我的计算机中删除了。
这是我使用的命令:
$ git rm -r -f src
rm 'src/main/java/Controller.java'
rm 'src/main/java/DTO.java'
rm 'src/main/java/Scheduler.java'
rm 'src/main/java/Server.java'
rm 'src/main/java/SimulationManager.java'
rm 'src/main/java/SimulatorFrame.java'
rm 'src/main/java/Task.java'
$ git rm -f -r target
rm 'target/classes/Controller$1.class'
rm 'target/classes/Controller$startSimulationListener.class'
rm 'target/classes/Controller.class'
rm 'target/classes/DTO.class'
rm 'target/classes/Scheduler.class'
rm 'target/classes/Server.class'
rm 'target/classes/SimulationManager.class'
rm 'target/classes/SimulatorFrame.class'
rm 'target/classes/Task.class'
$ git rm -f pom.xml
rm 'pom.xml'
$ git rm -f pt2019_30222_tomoiaga_andreistefan_assignment_2.iml
fatal: pathspec 'pt2019_30222_tomoiaga_andreistefan_assignment_2.iml' did not match any files
$ git commit -m "delete commit"
[master a6c5d68] delete commit
22 files changed, 1352 deletions(-)
delete mode 100644 .idea/.name
delete mode 100644 .idea/compiler.xml
delete mode 100644 .idea/misc.xml
delete mode 100644 .idea/vcs.xml
delete mode 100644 .idea/workspace.xml
delete mode 100644 pom.xml
delete mode 100644 src/main/java/Controller.java
delete mode 100644 src/main/java/DTO.java
delete mode 100644 src/main/java/Scheduler.java
delete mode 100644 src/main/java/Server.java
delete mode 100644 src/main/java/SimulationManager.java
delete mode 100644 src/main/java/SimulatorFrame.java
delete mode 100644 src/main/java/Task.java
delete mode 100644 target/classes/Controller$1.class
delete mode 100644 target/classes/Controller$startSimulationListener.class
delete mode 100644 target/classes/Controller.class
delete mode 100644 target/classes/DTO.class
delete mode 100644 target/classes/Scheduler.class
delete mode 100644 target/classes/Server.class
delete mode 100644 target/classes/SimulationManager.class
delete mode 100644 target/classes/SimulatorFrame.class
delete mode 100644 target/classes/Task.class
$ git push origin master
Enumerating objects: 3, done.
Counting objects: 100% (3/3), done.
Delta compression using up to 8 threads
Compressing objects: 100% (2/2), done.
Writing objects: 100% (2/2), 227 bytes | 227.00 KiB/s, done.
Total 2 (delta 1), reused 0 (delta 0)
To https://bitbucket.org/andreistefantomoiaga/pt2019_30222_tomoiaga_andreistefan_assignment_2.git
5ca3e67..a6c5d68 master -> master
$ git rm -f pt2019_30222_tomoiaga_andreistefan_assignment_2.iml
rm 'pt2019_30222_tomoiaga_andreistefan_assignment_2.iml'
$ git commit -m "delete commit"
[master 16ca832] delete commit
1 file changed, 2 deletions(-)
delete mode 100644 pt2019_30222_tomoiaga_andreistefan_assignment_2.iml
$ git rm -f pt2019_30222_tomoiaga_andreistefan_assignment_2.iml
fatal: pathspec 'pt2019_30222_tomoiaga_andreistefan_assignment_2.iml' did not match any files
$ git push origin master
Enumerating objects: 3, done.
Counting objects: 100% (3/3), done.
Delta compression using up to 8 threads
Compressing objects: 100% (1/1), done.
Writing objects: 100% (2/2), 238 bytes | 238.00 KiB/s, done.
Total 2 (delta 0), reused 0 (delta 0)
To https://bitbucket.org/andreistefantomoiaga/pt2019_30222_tomoiaga_andreistefan_assignment_2.git
a6c5d68..16ca832 master -> master
$ git reset HEAD \*
Unstaged changes after reset:
M Documentatie/Documentatie.docx
$ git reset --hard
HEAD is now at 16ca832 delete commit
$ git rm
usage: git rm [<options>] [--] <file>...
-n, --dry-run dry run
-q, --quiet do not list removed files
--cached only remove from the index
-f, --force override the up-to-date check
-r allow recursive removal
--ignore-unmatch exit with a zero status even if nothing matched
$ git reset
$ git reset HEAD
我需要恢复我的项目,如果可能的话,我也认为我可以从 Intellij 恢复它,但我不知道如何恢复。
我想恢复特别是 src 文件夹
答案1
您的文件和本地更改都消失了。
您现在可以恢复
- 之前的 git 修订版(没有本地更改)
- 来自 Intellij(如果可能)
- 从你的目标目录 - 不要运行
mvn clean
- 来自上次构建/部署的 JAR/WAR 文件并反编译 .class 文件
- 从备份