私はいくつかのファイルがbitbucketリポジトリから削除されると思い、git rmを実行し、そのファイルもコミットした後、そのファイルが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ファイルのデコンパイル
- バックアップから