DEV Community

Discussion on: Confused by git? Here's a git crash course to fix that 🎉

Collapse
 
chrisachard profile image
Chris Achard

If I understand correctly, what you want is to add the extra files to the staging area with:

$ git add FILE

and then you can add them to the most recent commit with

$ git commit --amend

Does that solve the issue?

Collapse
 
m_starca profile image
marko

Is this also working for remote last commit?
Thank you.

Thread Thread
 
chrisachard profile image
Chris Achard

If you want to change a remote commit, you'll have to do this, and then push with -f (which is a force push).

HOWEVER! Be careful with force push. If you accidentally force push to the wrong branch, then it can really mess you up, and if you have teammates who have already downloaded a public branch (like master), then force pushing to master isn't a good idea.

If you've already pushed to a public branch, the better choice is probably to just make a new commit.

Thread Thread
 
m_starca profile image
marko

I will keep that in mind. Thank you.