Join egghead, unlock knowledge.

Want more egghead?

This lesson is for members. Join us? Get access to all 3,000+ tutorials + a community with expert developers around the world.

Unlock This Lesson
Become a member
to unlock all features

Level Up!

Access all courses & lessons on egghead today and lock-in your price for life.


    Add a file I’ve forgotten to add to my last commit


    You committed your work to the repository and just realized that you’ve forgotten to include some of the files. Let’s see how we can fix that by leveraging git --amend to include the missing files as well. Note: This only holds if you did not yet push your changes to the remote repository



    Become a Member to view code

    You must be a Pro Member to view code

    Access all courses and lessons, track your progress, gain confidence and expertise.

    Become a Member
    and unlock code for this lesson
    orLog In




    Instructor: In my repository here, I have added a new Angular component, which is that shared folder here, which I've added to that shared module. I am just adding all of this, and I am committing it. If I take a look at the log, we can see that we have added the commit here on top of master.

    Now, I forgot to add that app folder component, which I just created also in my app component. Let's jump over to the editor and correct that. In the editor here, I'm opening up that app component. Rather than having here the folder, I'm now using the new component I just created.

    Back in our terminal, we can see here the modified file. What I would like to have is, of course, add this to that last commit, to add new app folder. It makes sense to have that included in there. That is already committed, however.

    What I can do is I can use the git commit amend command. First of all, I am adding my app folder to the staging area. Now, it's ready to be committed. Now, I do a git commit, and I add that amend. If I hit enter, will open up the editor again.

    We now see that we got that modified file included in our commit changes as well. We can leave the message as it is. I'm just saving. Now, if I do a git log, we can see that the commit message is still here. It didn't change, but our app component modification has been integrated in that last commit.