Skip to content

Instantly share code, notes, and snippets.

@srikanthmanda
Last active May 22, 2021 15:20
Show Gist options
  • Save srikanthmanda/c74a85b457500063752e8332640aa103 to your computer and use it in GitHub Desktop.
Save srikanthmanda/c74a85b457500063752e8332640aa103 to your computer and use it in GitHub Desktop.
Git Tips

Git Tips

Amending a Commit

git commit -a -m "wrong commit, needs changes"    # commit only staged changes, miss untracked changes
git add forgotten_file edited_file ...            # stage the changes to fix previous commit
git commit --amend --no-edit                      # commit staged changes, without editing commit message
git commit --amend -m "revised commit message"    # edit commit message, and commits staged changes if any

git commit --amend --reset-author                 # revise commit author info (for when done as wrong user)


Undoing a Commit

  • revert creates new commit(s) to undo commit(s).
  • reset discards a commit.

Following command discards the last commit completely.

git reset --hard HEAD~1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment