Useful git commands

Add a file to the staging area

git add <file>

To add all files in the current directory, use . in place of <file>.

git add .

Commit Changes

Commit changes that are already tracked and staged

git commit -m "<message>"

If you want to add all changes made to tracked files & commit

git commit -a -m "<message>"

# or

git commit -am "<message>"

Amend or change the last commit message

git commit --amend

Amend and add new changes to the last commit

git commit -a --amend
1 Like

Find branches the commit is on

git branch -a --contains <commit>