I will describe how to make your life easier as a programmer with these useful tips on using Git. Before reading this, I recommend that you have a basic understand on how Git works. Essential Command Line Argument My most used argument with git is probably . It is actually a command line argument. When you type this, the last used argument is replaced. For instance: !$ Type in the command line mkdir myFolder Then type to move into the recently created folder cd !$ In the above example, will be translated into , and this is a bit simple, but think about the times you forgot to stage your files before committing: cd !$ mkdir myFolder , but you forgot to add the src folder git commit -m'feat: Add new kickass feature' Then you can write , saving you from typing the whole commit message again git commit src/ !$ I know that you can press the , , to get the previous used command, and sometimes that can be just as easy. pressing , to move the caret to the beginning of the command, and then use to move one word at a time, and input where it needs to be. This is also something I use quite often. up key ↑ ctrl+a alt + → src/ Include Changes In the Previous Commit I almost always catch typos, excess whitespace, or missing new lines after I make a commit. My best advice for adding these changes is to add them to the previous created commit. You don't want to mess up the git history more than you have to. Use the to accomplish this. --amend Use to add your changes to the previous commit. git commit --amend By default, on Mac at least, the terminal will open , and you will see the previous commit message. Unless you want to add more to the message, you can type which saves the commit message as is, and quits . Vim :wq Vim But I already pushed the changes to the repository. I cannot change the commit anymore. Don't worry. You can still amend the last commit, but you need to force push the changes to the repository. If you try to amend a commit that is already pushed to the repo, you will get an error message similar to this ! [rejected] master -> master (non-fast-forward) error: failed to push some refs to 'git@github.com You might get a hint, telling you to pull the changes from repo, but this will create a conflict in your repository, and you need to create a new merge commit to fix it. This is not what we want. Instead, force push the changes you amended. to add to the previous commit git commit --amend to override the changes in the repo git commit origin yourBranch --force Using is a bit scary, because you could loose work permanently. Use it with care, and when you are 100% sure you know what you are doing. It is a powerful command, and with great power comes great responsibility. --force I Want to Undo My Previous Commit This is somewhat the opposite of the previous section. Instead of adding changes, we want to undo them. I make a lot of mistakes as a programmer, and one of them is committing the wrong files to the wrong branch. What do I do? I want to keep my changes, but remove them from the branch. In order to do this, we need to reset the change: will reset the last commit, and you keep your workspace changes. (passing instead of means you will discard your workspace changes) git reset HEAD~1 --soft --hard --soft Now you can change branch, and commit the changes to the correct one. But I already pushed the changes to the repository. I cannot change the commit anymore. Don't worry. We have a way of solving it, and it involves a force push this time as well. to undo the commit, but keep the changes in our workspace git reset HEAD~1 --soft to change the git history in our repo git push origin yourBranch --force Now you can change branch, and commit the workspace changes. Summary replaced with last used argument !$ append changes to the previous commit git commit --amend undo the latest commit git reset HEAD~1 keep workspace changes --soft discard workspace changes --hard overwrite existing code in repository --force