Skip to main content

Committing work

Examples of git commands to commit work.

Stage all modified files for commit

git add .

Commit with staging files and adding a commit message

git commit -am "Commit message"

Save non-commited work to make pull

If you need to make a pull, but you have made some modifications you cannot commit for now, you can use a combination of git stash - git stash pop commands.

The process can be the following:

  • save non-commited work:
git stash
  • temporarily checkout another branch

  • checkout your working branch

  • apply your saved changes:

git stash pop

Discard all changes up to the most recent commit

git reset --hard

Modify the most recent commit

If you need to modify the most recent commit without changing the commit message:

git commit --amend --no-edit