如何恢复使用git rm删除的所有文件

我在玩git,我不太喜欢它,我对此有些了解,而我试图让.gitignore在另一个分支上工作,所以我发布了

function update ()
{   
    //Declare constants for movement
    const arrowMoveAmt = 1500;
    this.player.setDrag(2000);

    //Rotation of the player
    if (this.cursors.up.isDown && this.player.angle > -45) {
        this.player.angle -= angleModifier;}

    if (this.cursors.down.isDown && this.player.angle < 0) {
        this.player.angle += angleModifier;}

    //Shooting with the spacebar
    if (Phaser.Input.Keyboard.JustDown(this.spacebar)) {

        //Animate the shooting
        this.player.anims.play('shoot',true);

        //Arrow shooting
        let arrow = this.physics.add.sprite(this.player.x,(this.player.y + 20),'arrow');

        //Make sure the arrow has a hitbox
        arrow.enableBody = true;
        //Let the arrow move
        arrow.body.immovable = false;
        //Edit arrow hitbox 
        arrow.setSize(50,15).setOffset(5,50);

        arrow.setGravityY(3600); //Gravity will affect the arrows
        //Arrow speeds
        arrow.setVelocityX(arrowMoveAmt);
        arrow.setVelocityY((this.player.angle * 50));

        this.arrows.push(arrow); //Add arrow to the array created earlier

        this.arrowSound.play(); //Play the sound

        //Reset the angle modifier for added difficulty
        angleModifier = (Math.random() + .1) * 2;
    }

    else if(target.body.touching.left) {

        //Variable for loop
        let i = 0;

        //Set initial position of new medals
        let firstMedalX = 180;

        //Loop to create multiple arrows
        while (i < this.arrows.length) {
            newArrows = this.arrows[i];
            newArrows.setGravityY(0);
            newArrows.setVelocityX(0);
            newArrows.setVelocityY(0);

            //Add 30 to the new medal's x position
            firstMedalX += 40;

            //Increment for every arrow shot
            i++;

            //Reset the player angle for difficulty
            this.player.angle = 0;

            // Move the arrows
            newArrows.x += 10

        }

        //Move the target
        target.x += 10;

        //Call the function to determine medal and pass the variable
        if(this.arrows.length <= 5) {
            //Only track the first five arrows
            getMedal(firstMedalX);
        }
    }

    //Function to decide medal,and where it goes
    getMedal = (value) => {
        //Gold medal
        if (410 < newArrows.y && newArrows.y < 435) {
            this.add.image(value,175,'gold_medal');
            score += 5;
        }
        //Silver medal
        else if (395 < newArrows.y && newArrows.y < 450) {
            this.add.image(value,'silver_medal');
            score += 3;
        }
        //Bronze medal
        else if (380 < newArrows.y && newArrows.y < 460) {
            this.add.image(value,'bronze_medal');
            score += 1;
        }
        else {
            this.add.image(value,'no_medal');
        }
        //Set the scoreboard to the new score
        scoreBoard.setText('SCORE: ' + score);
    }
}

因此,我一直在寻找git rm的一些选项,不小心按下Enter键并键入$ git rm -r --cached . fatal: pathspec '.' did not match any files ,现在我几个月来一直在工作的几乎所有文件都消失了,我将如何恢复它回来吗?

alno_wang 回答:如何恢复使用git rm删除的所有文件

简单,重置HEAD。

git reset HEAD

我刚刚发现了类似的问题。请参阅此question以获取更多说明。

,

在当前分支(已完成rm的地方,更现代的还原文件的方法是使用git restore(Git 2.23 +):

git restore --source=HEAD --staged --worktree -- .
本文链接:https://www.f2er.com/3147294.html

大家都在问